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) ...
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) ...
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 | ...
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...
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...
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...
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...
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"/> ...
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 ...
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...
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...
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...
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 (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-...
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. ...
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; ... } ...
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...
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...
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...
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...
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. ...