orm

Django subquery using QuerySet

Is it possible to perform a subquery on a QuerySet using another QuerySet? For example: q = Something.objects.filter(x=y).extra(where=query_set2) ...

Versioning in SQL Tables - how to handle it?

Here's a fictional scenario with some populated data. For tax purposes, my fictional company must retain records of historical data. For this reason, I've included a version column to the table. TABLE EMPLOYEE: (with personal commentary) |ID | VERSION | NAME | Position | PAY | +---+---------+------------+----------+-----+ | 1 | ...

How established are ORMs (object relational mapping) in the world of databases

I'm not a database admin or architect, so I have to ask those who do it 24/7. How established is the concept of an ORM (object relational mapping) in the world of database administration and architecture? Is it still happening, widely approved but still in its early stages, or is generally disapproved? I'm learning this area and would li...

How to make this tutorial work? Could not determine type for: java.util.List, at table: College, for columns

Now, i am learning hibernate, and started to using it in my project. It is a CRUD application. I used hibernate for all the crud operations. It works for all of them. But, the One-To-Many & Many-To-One, i am tired of trying it. Finally it gives me the below error. org.hibernate.MappingException: Could not determine type for: java.util.L...

define jpa entity classes outside of persistence.xml

Is there a way to define jpa entity classes outside of persistence.xml (i.e. in a separate file)? Being able to not have persistence.xml as an external file would also suffice. Thanks in advance, Steven Edit: Sorry I was not clear. This is in a Java SE environment. Also, I would like to not have a listing of some.class.AClass in my pe...

Hibernate creates duplicate entries in the database.

I have a database structure which is something like the one described below. "Universe" can contain any number of "Items". "Person" may have a "Box" which refers to one or more of the "Items" in the "Universe" Universe, Items, Person, Box are all database tables. Box is like a join table for the Person and Items. Note: I am using ja...

Hibernate and Postgresql - generator class in hibernate mapping file

Hi, The ids in my postgresql database are auto-incremental (there are sequences defined in a database). When creating a hibernate mapping files I set the class generator to increment: <class name="model.Names" schema="public" table="names"> <id name="id" type="int"> <column name="id"/> <generator class="increment"/> ...

most common cause of OutOfMemory errors when using Hibernate?

Pardon the newbie question. My data model is really simple (two tables; 200 rows in one, 10,000 in the other; natural join between both). I'm using Hibernate to attempt a simple read/update on these tables. Doing so keeps throwing OutOfMemory errors (1GB assigned to my JVM). This seems very unlikely due to natural memory needs, and ...

JPA/hibernate big collections

Hi, In a scenario with two types of entities, Parent and Child: Parent - @OneToMany Collection children; The default is to have lazy loading on the collection of children. This model works great for small numbers of children, but if the number grows very large this seems unsustainable. So for occasions where I think the number of chi...

JPA synchronizing entity accessors

Hello guys, Here's the setup: the entity class has the collection of other entities that is loaded lazily. The trick is, I need to perform some data-related work (for example, I want to calculate certain checksum with the elements of collection). The trick here is that I want to avoid at all costs the race conditions like: "someone ha...

Changing the discriminate-column in a single table sub class with JPA inheritance

I have a domain model that looks like this: Instruction | \ Money Other / \ Unit Cash and I want to map this model to my DB using JPA. All classes map to the same table in the DB, (T_INSTRUCTION). So I started out with jpa's SINGLE_TABLE inhertance strategy. Separating the Money and Other classe...

Safely clearing Hibernate session in the middle of large transaction

I am using Spring+Hibernate for an operation which requires creating and updating literally hundreds of thousands of items. Something like this: { ... Foo foo = fooDAO.get(...); for (int i=0; i<500000; i++) { Bar bar = barDAO.load(i); if (bar.needsModification() && foo.foo()) { bar.setWhatever("new whatever...

Is clean SQL achievable on Linq to SQL?

Is clean (or should I say performant) SQL achievable in Linq to Sql? I wanted the Linq to Sql produce this code: SELECT C.CustomerID, COUNT(O.CustomerID) AS N FROM Customers C LEFT JOIN Orders O ON O.CustomerID = C.CustomerID GROUP BY C.CustomerID And I follow this code: http://stackoverflow.com/questions/695506/linq-left-join-group-...

Does Stackoverflow use Linq to SQL generated classes directly?

I wonder if someone knows whether Stackoverflow uses the classes generated by Linq to SQL directly in their application or how they do it. Thanks. ...

@Id for oracle.rowid

Howto declare @Entity class for oracle table w/o PK? I has received the error message: Column "rowid" cannot be resolved on table "LOG" when doing mapping like this: @Entity public class Log implements Serializable { ... @Id private ROWID rowid; ... } ...

why is Hibernate selecting same columns twice?

Hibernate: /* load entities.Department */ select department0_.name as name4_0_, department0_.id as id4_0_ from J_DEPT department0_ where department0_.name=? Hibernate: /* load one-to-many entities.Department.employees */ select employees0_.dept as dept4_1_, employees0_.i...

Android object handling / persistence

I am pretty far into my first Android application, and I have the sneaking suspicion that I'm "Doing It Wrong". My app talks to a Ruby on Rails server and serializes objects back and forth via XML. Before I knew what was happening, I found myself knee deep in writing my own crappy ORM, a problem which is compounded by the fact that I h...

unexpected JPA results

Hi, Im learning JPA and having problems. My main problem is when i join my entitys and dont quite understand why im getting the results i am .. and its realy slowing my progress if someone could help i would be very greatful. Entitys College @Entity @NamedQueries({ @NamedQuery(name=College.allCollegeQuery,query="SELECT col FROM C...

How to swap out hibernate.cfg.xml properties?

Hello all! I've got a hibernate configuration file called hibernate.cfg.xml. In this file there are hard-coded property names like: <hibernate-configuration> <session-factory> <property name="hibernate.connection.username">root</property> <property name="hibernate.connection.password">mysecretpassword</property> ... </s...

Partially object loading in Hibernate

I have a class that sometimes is not necessary to load fully. Can I load it partially, or I need to create light version of class (and new mappings for it)? For example: class Message with id, title, body, author, timestamp. When I want to delete message i need only two fields id, author. ...