entity 2 « Query « JPA Q&A





1. Report Queries vs Entity Retirieval and Returning in DTO[]    forum.hibernate.org

I think this scenario is interesting and I would assume is used in many applications so it would be nice to hear some opinions... 1. Using Hibernate 3.2.2 (latest as of this writing), we have an application that does only read-only retrieval of data and has absolutely no persistent requirements at all. What I'd like to do is retrieve an array ...

3. Query entity from db including collections    forum.hibernate.org

Hello, i've got one problem. Maybe there is a simple way to manage it... I've got an entity CustomerConfiguration which includes a Set of Area-entities. Every Area-entity includes a Set of SRAgreement-entities. CustomerConfiguration -> Area-Set with Area-Objects -> SRAgreement-Set with SRAgreement-Objects Now i want to load the complete CustomerConfiguration-Object from DB, including all initialized Sets. I've tried with the following query: ...

5. Criteria.DISTINCT_ROOT_ENTITY    forum.hibernate.org

6. Problem with entity-name in HQL query    forum.hibernate.org

7. Querying for non-entity values    forum.hibernate.org

9. Best Practice for finding particular entity in a Collection?    forum.hibernate.org

I have two objects related by a one to many. From the one side, I want to find a particular object in the collection based upon an attribute value that can vary per request. Possibilities include: - load entire collection and iterate until you find it - write method with a hql query rather than using collection We're currently using the ...





10. Problem in querying non entity element...Need your help    forum.hibernate.org

Hibernate version:3.0 My Domain Class : -------------------------- @Entity class Definition { private List m_actions; ..... ..... @CollectionOfElements(fetch = FetchType.EAGER) @IndexColumn(name = "sortOrder") @Cascade(value = { CascadeType.ALL }) @Column(length = 500) public List getActions() { return m_actions; } public void setActions(List actions) { m_actions = actions; } } I've created query like this... ----------------------------------- select id, actions from Definition; It throws exception ...

11. getting entities with distinct column values.    forum.hibernate.org

Hello All, I have a entity namely Link which holds the links that a user has visited. It has "url", "createdTime" and some other properties. What I try to do is get last 3 Favorite objects, but I want the "url" to be distinct For example if user has "www.foo.com", 27/08/2007 "www.bar.com", 26,08/2007 "www.foo.com", 26/08/2007 "www.other.com", 25/08/2007 in his table, when ...

12. Question about query cache and versioned entities    forum.hibernate.org

Hibernate version: 3.2.2 Name and version of the database you are using: Postgres 8.2.4 I have a persistent versioned entity loaded in hibernate session A. I make a change to this entity in hibernate session B. I can see that the version number of this entity has been incremented after the update in session B. I reload the entity (via a ...

13. P*morphic query breaks if entity proxy already xist in sess    forum.hibernate.org

Hi Guys My hibernate version is 3.2.5. JBoss is 4.0.5. Java is jdk1.5.0_08. I'm executing a polymorphic query and expect an Individual instead of the Party entity I'm getting. Party is the super class for Individual and Organisation. I'm using table-per-class-hierarchy. I've found that the reason this occurs is because earlier in the transaction another query has the side effect of ...

14. SELECT SENTENCE TO ENTITIES    forum.hibernate.org

15. BY USING ENTITIES OR WITH PROJECTIONS    forum.hibernate.org

Is There any way to get ...as.. suppose we have a table students in that name,id,courseid, pic are the columns.. We have to get the records from the database only name , id & courseid thatsall, we dont need pic because of blob. yes, i know its easy to do with create sql query,projections and native sql,but by using those we ...

16. Get Entities from a native query    forum.hibernate.org

Hello hibernate community Short question: Is it possible to get an array of objects mixed with entities and native results from a native query? I have do make a select from different entities AND one table which isn't in my hibernate mapping. I know that's possible to get a array of objects with entities from a native query. But I need ...





17. New entities are not flushed before executing update query    forum.hibernate.org

Newbie Joined: Mon Aug 25, 2008 9:34 am Posts: 3 Hi, I'm not sure about the following issue - hopefully some of you can help me with the following: 1. There are two simple tables/entities: person and representatives (mapping files below) 2. There are 2 Sets for a person: - persons representing the current person - persons to be represented by ...

18. Unnecessary entity (just for querying)    forum.hibernate.org

Hi, Given two tables: TableA(col aid,col value) TableB(col aid, col otherid) I have the otherid and I'd like to get the TableA entity with the aid that corresponds to that otherid. Do I really need to create an TableB entity just for the purpose of being able to retreive a TableA entity? (In reality TableB has 20+ column). Thanks!!

19. How to order by joined object, e.g entity.createdBy.lastName    forum.hibernate.org

Hi all, I have been wondering how to order by a joined object, e.g. an project creator's lastName. Now, I got an idea, but I am not sure whether it is good or not, or maybe somebody has a better one. Welcome other people to share. Thanks in advance. Following is my sql and entity classes: Code: "select new Project (creator, ...

20. find all the entities    forum.hibernate.org

21. find state of entity    forum.hibernate.org

Newbie Joined: Wed Dec 17, 2008 12:17 pm Posts: 11 mmerder wrote: You can use session.contains to check if the object is associated to the current session. here is the code from hibernate which determines the state of entity and how good is using session.contains() compared to this ? Code: protected int getEntityState( ...

22. Aggregate function operating an abstract entity    forum.hibernate.org

PRONOSTICO_PRODUCTO_SEQ ...

23. Session.refresh() - entity name    forum.hibernate.org

Hello The org.hibernate.Session interface takes an "entityName" argument for most operations such as save, update or delete. However the refresh() method does not do so, which gives be an org.hibernate.MappingException "Unkown entity" when I use it. I need to refresh an entity after doing some SQL batch updates. I guess using Session.flush() followed by Session.clear() or Session.evict() is a workaround, but ...

24. Equinox (OSGi) and JPA/Hibernate - Finding Entities    forum.hibernate.org

Newbie Joined: Tue Jul 22, 2008 5:11 pm Posts: 16 I am trying to use Hibernate/Spring in an OSGi (Equinox) environment. It works great if I explicitly point it to the Entity classes in the Persistence.xml: Code: com.es.t.eee.domain.StuffSource com.es.t.eee.domain.PostalAddress What I want is for Hibernate to "find" all of ...

25. Entity refreshing problem    forum.hibernate.org

Hi. I have a problem with a refreshing entity. Please look at the very simple example: class A { ... private static void test() throws Exception { EntityManagerFactory factory = Persistence.createEntityManagerFactory("PC"); while(true) { EntityManager manager = factory.createEntityManager(); List entities = manager.createNamedQuery("getEntities").getResultList(); for(Entity entity : entities) System.out.println(entity); manager.close(); Thread.sleep(1000); } } ... } Next i run this test. If i update some ...

26. Ordering entities by an aggregation    forum.hibernate.org

Hi, I'm in the following situation: I have Invoices, Products and ProductEntries. In my simple application I want to display the Invoices along with the sum of their ProductEntries and be able to sort them. So I'll have to order it according to the SUM of the values of the entries. My problem is that I'm unable to get Invoices from ...

28. HQL query with entities and scalar values    forum.hibernate.org

29. select entity where collection contains at least one of    forum.hibernate.org

Hi, This should trivial but I'm banging my head to figure it out ... I have a Restaurant Entity which has a mapped collection of FoodTypes named foodTypes. I want to find all the restaurants of which the foodTypes collection contains at least one of the FoodType that are in a Set foodTypesParam that I would pass as a Parameter. In ...