entity 1 « Query « JPA Q&A





1. How can I find out the length of a column in a JPA @Entity?    stackoverflow.com

I've got a String column defined with

@Column(length = 4000)
The attribute contains log information and can be longer than the defined length. In this case, the field can be safely truncated ...

2. Hibernate query for entity based on whether related entity property is null?    stackoverflow.com

I have the following mapping:

<class name="Customer">
  <!-- actually one-to-one for all intents and purposes-->
  <many-to-one name="specialProperty" class="SpecialProperty" cascade="all" not-found="ignore" insert="false" update="false" column="id" unique="true"/>
</class

<class name="SpecialProperty" lazy="false">
     ...

3. Query partial entities with JPA    stackoverflow.com

I have a JPA entity similar to;

public class Inventory {
 private String productname;
 private String manufacturer;
 private Float retailprice;
 private Integer unitssold;
 private String ourcomment;
}
In about 2 out of 5 queries ...

4. Hibernate Entity sort column configuration    stackoverflow.com

Is there a Hibernate configuration (hopefully an annotation on a classes mapped @Column field) that would let me sort a collection of entities associated with the loaded entity by a given ...

5. NHibernate HQL Group by Entity    stackoverflow.com

Is it possible to run a query similar to this one in HQL without having to specify all of the column names.

select med, MAX(med.PrescriptionLines.Prescription.PrescriptionDate)
    from Medication med
  ...

6. Querying entities which have a specific collection entry using HQL    stackoverflow.com

I have Item objects which have a collection of attributes defined as a map. Now I want to retrieve all objects which have a specific attribute (by name, locale and value) An ...

7. Apply native SQL where clause to Nhibernate query for entity    stackoverflow.com

I have this problem. I have a module (module 1) that use Nhibernate to manage entity persistence; this module interacs with an other module (module 2). The "module 2" allows to generate dynamically ...

8. how do I group by a property of a related entity in a criteria?    stackoverflow.com

I'm writing a criteria that should group the results by a property of a related entity. I've tried using an alias, tried using the property path itself, but so far I ...

9. Second level cache for entities with where clause    stackoverflow.com

I am wondering where the hibernate second level cache works as expected if I put a where clause in the hbm.xml class definition:

<hibernate-mapping>
  <class name="com.clazzes.A" table="TABLE_A"
   mutable="false" ...





10. Select non-entities with JPA?    stackoverflow.com

Is it possible with JPA to retrieve a instances of a non-entity classes with native queries?
I have a non-entity class that wraps two entities:

class Wrap{
  Entity1 ent1;
  Entity2 ent2
}
@Entity
class ...

11. Select all entities of exact class, but not derived from it using NHibernate Criteria API    stackoverflow.com

I have two classes: Cat and DomesticCat, that extends Cat. I want to select all Cats, but no oneDomesticCat. How to do it using NHibernate criteria API?

12. Refresh of an Entity with a colllection throws a UnresolvableObjectException when an Element of the collection got deleted    stackoverflow.com

We have a two tier Swing application using Hibernate. Sometimes we manipulate an object in one session (A), which we know in another session (B) as well (two different Java Instances, ...

13. HQL - find entity where property x is highest    stackoverflow.com

Can HQL queries do this? "get the UserEntity where the property creationTimestamp is the most recent of all UserEntities". Essentially a query to return the "newest user" in our program where each UserEntity ...

14. Hibernate: Refreshing an object with specified entity-name    stackoverflow.com

In my application, I have a model with mixed static (POJO) and dynamic (Map) entities. As I wanted to have unqualified entity names all over the place, I gave the mappings ...

15. Refreshing entity instance after using merge in hibernate?    stackoverflow.com

am using hibernate merge method, to deal with detached instance from entity, and i thought that the return of this method will be a new fetched instance from database as hibernate ...

16. JPA/Hibernate can't create Entity called Order    stackoverflow.com

I'm using Hibernate/JPA and have an @Entity object called Order, pointing at a MySQL database using Hibernate's dynamic table generation i.e. generate tables at runtime for entities. When Hibernate creates the ...





17. Is there a way to define NamedQueries outside of entity?    stackoverflow.com

I use Netbeans as IDE and use the wizards to generate Entities. If I want to define custom NamedQueries (not the ones auto generated) how can I define those outside of ...

18. JPA2 Criteria queries on entity hierarchy    stackoverflow.com

suppose i have the following entity domain:

@Entity
@Inheritance(strategy=InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name="TYPE")
public abstract class Entity1 {
//some attributes
}

@Entity 
@DiscriminatorValue("T1")
public class Entity2 extends Entity1 {
    @OneToMany(fetch=FetchType.EAGER, cascade = { CascadeType.ALL }, mappedBy="parent")
    ...

19. Hibernate's session-per-conversation & query unflushed entities    stackoverflow.com

here's the context : we are currently writing an application which is web based (flex front end). The server side is implemented with Java, using hibernate for ORM.
The specificity of this application ...

20. In Hibernate Envers is it possible to query ALL entities for a given revision?    stackoverflow.com

I'm looking at Hibernate Envers to solve two problems for me. First is auditing, fine. Second is the ability to roll-back a change made in a revision. ...

21. Prevent Hibernate N+1 Selects when grouping by an entity    stackoverflow.com

I have a Hibernate Criteria object that I build thusly:

Criteria obsCriteria = hibernateTemplate.getSessionFactory()
  .getCurrentSession().createCriteria(Observation.class);

ProjectionList projection = Projections.projectionList()
  .add(Projections.rowCount())
  .add(Projections.avg("value").as("avgScore"))
  .add(Projections.avg("type.score"))
  .add(Projections.max("date"))
  .add(Projections.groupProperty("observedSubject"));
criteria.setProjection(projection);
This produces a ...

22. Is the second-level cache support for caching the query result exclude the entity    stackoverflow.com

Normal query manner:

Session sess=factory.getCurrentSession();
sess.beginTran....();

String hql="from Entity en where en......";
Query q=sess.createQuery(hql).setCacheble(true);
List<Entity> list=q.list();
In this case,the object in the list are "entity"s. They will be cached. However I wonder if cache would work if the ...

23. HQL: How to select all entities distinct by some column?    stackoverflow.com



A simple question:
In this example I need to retrieve all objects, but these objects must have distinct msgFrom fields.
When I use

List<Message> list = getHibernateTemplate().find("select distinct m.msgFrom from Message m WHERE msgTo ...

24. Querying a hibernate entity with two one-to-many collections    stackoverflow.com

I am selecting a number (x) of entities Foo using Hibernate. Each foo has one-to-many collections bar and baz that are set to lazy fetching. I will need to ...

25. Hibernate: Unable to find entity which clearly exists, why not?    stackoverflow.com

I have entity class which is used to model a weather station, and it includes a unique string property "code". I also have an entity class which is used to ...

26. How to declare named queries oustide Hibernate entity classes?    stackoverflow.com

I have a data access class that exposes basic operations for an entity class used on a web site:

public class UserDataAccessService {

   public User login(User u)...
   public ...

27. How to project instances of the original root entity in a hibernate criteria query as part of the projectionList?    stackoverflow.com

Assuming a model where A has a collection of B's, and each B has two collections--one of C's and one of D's--I need to count the total number of C's and ...

28. Hibernate find entities not in a collection    stackoverflow.com

I have an entity CategoryModel. One of the properties is copied below:

@OneToMany(cascade = CascadeType.ALL)
private List<CategoryModel> children;
How can I perform a query that will return all CategoryModel entities that are not in ...

29. Problem in HQL when try to get count of a property (that is entity) and its value    stackoverflow.com

In my project, I have two entity, first PaperEntity contains several properties (consisting of value types and also reference types -reference to other entities-) and second is PaperStatusEntity. PaperEntity has a property ...

30. HQL: query only base table from entity    stackoverflow.com

I have this mapping

<class name="Person" table="person">
<id name="Id" column="id" type="Int32" unsaved-value="0">
  <generator class="native" />
</id>

<property name="Code" column="code" type="String" not-null="true" />
<property name="FirstName" column="firstName" type="String" not-null="true" />
<property name="MiddleName" column="middleName" type="String" not-null="false" />
<property name="LastName" column="lastName" ...

31. Java EE, EntitiManager Query, SELECT JOINED entities    stackoverflow.com

This is what I have (of course in a sintetic form)

@Entity
public class Event {
    @Id
    private int id;
    private String name;
  ...

32. Finding the recently deleted entities using Hibernate envers    stackoverflow.com

So my problem is that I need to find all the recently deleted entities of a particular class, that is the entities which have been deleted since a particular timestamp. Specifically, ...

33. JPA: Query that returns multiple entities    stackoverflow.com

I'm writing a JPQL query that joins across three tables. In my resultlist I would like to get all three entities per matching row (hope that makes sense). Any ideas? Hibernate 3.x is ...

34. delete query in JPA2 with related entities    stackoverflow.com

I'm trying to do a bulk delete

@NamedQuery(name=CalcData.DELETE, 
query="delete from CalcData as model where model.dataLocation.locCountries = :locCountries and model.locPeriod= :locPeriod")
The prbolem is that hibernate translates this to
Hibernate: 
delete 
from
   ...

35. problem finiding an entity in a named query    stackoverflow.com

Any idea on how to make an entity identifyable in a JPQL named query? I have a named query in an entity that references another entity. But on running the query ...

36. ORM framework compare to direct query in database    stackoverflow.com

I want to write a program for warehousing. Can anyone guide me to use framework for database layer. I have used entity framework before but I did not enjoyed that because it ...

37. Hibernate Native SQL Query retrieving entities and collections    stackoverflow.com

This is my situation, I have two basic POJO's which I've given a simple hibernate mapping :

Person
  - PersonId
  - Name
  - Books

Book
  - Code
  - ...

38. Hibernate entity property defined by a query    stackoverflow.com

I try to implement document modifications tracking system with Java and Hibernate. Every mod to document is saved with autor and timestamp. To get the creator of document I need to ...

39. Prevent entity from being created, but need entity for native query    stackoverflow.com

I have a native query that executes a stored procedure and the results is mapped to an entity, this works fine but the thing is the entity is created in the ...

40. How to get a distinct user entity in Hibernate for each user address using criteria    stackoverflow.com

i'm implementing a search routine with hibernate criteria to find registered users. Each user can have one or more addresses. i've build the following structure and i add it the restirctions ...

41. HQL error with subquery for a related entity    stackoverflow.com

I've been having problems trying to retrieve a related entity using an HQL subquery. I have three entities: a Customer entity, an Account entity and an additional entity which I called ...

42. HQL NHibernate - "where clause" of a collection of an entity    stackoverflow.com

I'm using NHibernate 3.2 Here is what i want to do (all atempts failed):

from Car c where (c.Tires.elements.Brand = 'Goodyear')
OR
from Car c, elements(c.Tires) as t where t.Brand = 'Goodyear'
Is it possible to ...

43. Refresh entities in JPA    stackoverflow.com

I'm confused about how I should refresh the state of entity that is already in the database. Being more specific, suppose I have "entity" persisted with a code like this:

EntityManager em ...

44. JPA native query, group function, different entity    coderanch.com

Hello all, I have got an exciting problem. I have got the following native query: String sql = "select max(nvl(a_date, b_dt)) as max_a" + ", min(nvl(a_date, b_dt)) as min_a" + ", max(c_dt_tm) as max_c" + ", min(c_dt_tm) as min_c" + " from date_table " + " where number " + " between '" + startNumber + "' " + " and ...

45. Hibernate can't find Entity!    coderanch.com

creat the webproject with myeclipse, and added hibernate capabilites, hibernate.properties: hibernate.connection.driver_class=com.mysql.jdbc.Driver hibernate.connection.url=jdbc:mysql://localhost:3306/worklog hibernate.connection.username=root hibernate.connection.password=acc the Java Persistence class is also configurated, its content: package mem; import javax.persistence.*; @Entity @Table public class Member implements java.io.Serializable { private static final long serialVersionUID = 1L; @Id @GeneratedValue @Column(name="id") private Integer id; @Column(name="username") private String username; @Column(name="password") private String password; public Member() { } public ...

46. Hibernate execute second select for each entity reference    coderanch.com

Hey, I have Person->Address->*Contacts (collection of elements) (in my model i have heirarchy with more levels). i use the following query: from Person person left join fetch Address address left join fetch address.contacts in the SQL that hibernate generate i notice that it excute select for each person references, so if i load 10 persons it will run 10 selects for ...

47. JPA Delete Entity and Refresh Collections containing Entity    coderanch.com

What is the best way to delete an entity and then refresh all of the places in the application that have a reference to it? I have two references to a particular entity and when I delete the entity I want the other location updated. Here is the scenario: Entity A has a collection (List) of Entity B (OneToMany). I obtain ...

48. Hibernate JPQL/HQL: aggregate functions show results of wrong table/entity joined twice    coderanch.com

|sf.roster.id|ga.id|sf.finalScore|sa.finalScore| |------------|-----|-------------|-------------| | 1| 3| null| null| | 1| 5| 71| 93| | 1| 11| 77| 80| | 1| 13| 65| 71| | 1| 16| 88| 90| | 1| 22| 58| 51| | 1| 23| 71| 75| | 1| 30| null| null| | 1| 32| 89| 86| | 1| 40| 62| 71| | 1| 42| 64| 60| | 1| 46| 73| ...

49. Static select for entity    forum.hibernate.org

50. Named Query Unknown Entity    forum.hibernate.org

52. Static select for entity    forum.hibernate.org

Hello, When starting Hibernate in debug mode I see thousands of statements like the following: [code]2009-12-11 18:16:43,754 DEBUG [org.hibernate.loader.entity.EntityLoader] - Static select for entity be.xyz.DimensieDefinitie: select dimensiede0_.SK as SK1_0_, dimensiede0_.ORM_VERSIE as ORM2_1_0_, dimensiede0_.CODE as CODE1_0_, dimensiede0_.NAAM as NAAM1_0_, dimensiede0_.VALIDATE_DIM as VALIDATE5_1_0_, dimensiede0_.WIJZIGINGSDATUM as WIJZIGIN6_1_0_, dimensiede0_.WIJZINGSAUTEUR as WIJZINGS7_1_0_, dimensiede0_.AANTAL_BUDD as AANTAL1_2_0_, dimensiede0_.AANTAL_AUDD as AANTAL2_2_0_, dimensiede0_.AFLEIDEND as AFLEIDEND2_0_, dimensiede0_.OPTIONAL as OPTIONAL28_0_, dimensiede0_.UD_CLASSNAME as ...

53. Failed to cached entities already fetched in previous query    forum.hibernate.org

I am working on a simple example to illustrate my problem. It consists of two entities, (Contact and PhoneNumber) with a one-to-many relationship between them. Contact -> PhoneNumbers My application queries a set of contacts and their corresponding phone number using a set of complex queries. Once these have been retrieved I am going some further processing and navigate the relationship ...

54. Hibernate execute second select for each entity reference    forum.hibernate.org

Hey, I have Person->Address->*Contacts (collection of elements) (in my model i have heirarchy with more levels). i use the following query: from Person person left join fetch Address address left join fetch address.contacts in the SQL that hibernate generate i notice that it excute select for each person references, so if i load 10 persons it will run 10 selects for ...

55. Entity cache expire clears query cache too.    forum.hibernate.org

I have two cache regions set up. One for the Employee entity and the other is for queries. I should say that my query results consist of lists of Employee objects. Problem is, when the entity cache times out, it also clears my query cache. It also does something strange to the query cache because it take 50 secs for the ...

56. HQL question : entities in 'in'-clause    forum.hibernate.org

57. many-to-one joined produce inserts while selecting an entity    forum.hibernate.org

Hi everyone, I have a problem with a many-to-one relationship. In fact my mapping works but I don't undesrtand what Hibernate is doing. I have "formation" object, this object can be associated with a "section" and this association contains an attribute "year". Code: CREATE TABLE formations_section ( fu_id INTEGER NOT NULL, sec_id INTEGER NOT_NULL, ...

58. Entity cache supported for "named queries/stored procs"?    forum.hibernate.org

Beginner Joined: Fri Dec 10, 2004 11:46 pm Posts: 37 Hi I'm experiencing this issue when calling a stored procedure. At first it works and then after a few calls it can no longer map the entity. I think it has something to do with caching. The cache expires and then it tries to load the entity directly. The sp is ...

59. What does Criteria.DISTINCT_ROOT_ENTITY do ?    forum.hibernate.org

62. Adding projections is turning off my entities    forum.hibernate.org

63. Extract single entity from criteria query result    forum.hibernate.org

Hibernate and JPA implementation. I am using Criteria query to create dynamic query. My generated query as bellow. select entity1.*,entity2.*,entity3.* from entity1 this_, entity2 entity2_1_, entity3 entity3_2_ where this_.column=entity2_1_.column and entity2_1_.column=entity3_2_.column(+) and this_.xxxxx = ? and this_.xxxxx = ? and this_.xxxxx = ? Collection xxxx = (Collection)Criteria.list(); Getting Exception : java.lang.ClassCastException: com.xxx.xxx..persistence.pojo.entity2E at org.hibernate.type.ComponentType.toLoggableString(ComponentType.java:400) at org.hibernate.pretty.MessageHelper.collectionInfoString(MessageHelper.java:307) at org.hibernate.loader.Loader.readCollectionElement(Loader.java:1008) at org.hibernate.loader.Loader.readCollectionElements(Loader.java:669) at ...

64. Criteria Projections to the root entity    forum.hibernate.org

Hi, when I use Criteria Projections, then I cannot get root entity anymore. E.g. createCriteria(Employee.class).setProjection(Projections.projectionList().add(Projections.sqlProjection("(SELECT DISTINCT...)", mySQLProj, Hibernate.INTEGER)).add(Restrictions...); Now, I want the result to be a List, or when I use AliasToEntityMapResultTransformer, I'd like to have a map of "Employee" and "mySQLProj". AFAIK to achieve this I can do: 1) add Projections.id() and then fetch Employee entities by id manually (em.find(...)). ...

65. Handling new entity creation with an eternal query cache    forum.hibernate.org

Newbie Joined: Wed Aug 25, 2010 9:14 pm Posts: 5 I have the following scenario: 1. query cache enabled, query cache region is eternal (never evicts). My query cache is massive (entire db is cached in L2 for performance reasons). 2. queries used in the query cache make strict use of natural identifiers to avoid query cache eviction upon update/delete/insert ( ...

66. Getting a single entity from a query    forum.hibernate.org

public class JCMSYearIndicator @OneToMany public List departmentMonths ; I would like to get the parent record with one child record from this @OneToMany mapping so I have used the following query [code]query = sessionFactory.getCurrentSession().createQuery( "from YearDepartment yearDepartment join yearDepartment.departmentMonths m WHERE m.id=?"); query.setInteger(0, 1234); temp = query.list();[/code] This returns a list of objects and each position has two objects - an ...

67. Session per conversation & query unflushed entities    forum.hibernate.org

Hi, here's the context : we are currently writing an application which is web based (flex front end). The server side is implemented with Java, using hibernate for ORM. Well, I'm not wrong with the forum I write to. The specificity of this application is that it implements a conversation with the user. That means that the user is opening a ...

68. Getting the entity name in an HQL query?    forum.hibernate.org

69. JPA2 Criteria API, using Entity as query parameter.    forum.hibernate.org

Newbie Joined: Mon Nov 15, 2010 9:54 am Posts: 1 I've been trying to implement QBE (Query by Example) functionality using plain JPA2 spec, while using Hibernate 3.5.5 as JPA2 implementaion. The problem i am stumbled upon is the following: I have implemented GenericDao with the following methods: Code: public List findByExample(T exampleInstance) { ...

71. 2 entities returned by a query while only one in DB    forum.hibernate.org

Newbie Joined: Fri Feb 18, 2011 2:19 pm Posts: 3 Hi, I've experienced some weird behavior with Hibernate recently and I haven't foudn anything which explains it yet. I have a simple piece of project with 2 classes : Speaker and Talk. A speaker can give multiple talks and a talk can only be given by one speaker. Here is my ...

72. Distinct Entity Criteria Returns Same Entity N-times    forum.hibernate.org

I have an entity which has a relationship with two child collections, as shown here: Parent +-- Child (collection) +-- GrandChild (collection) What I want to have returned is the list of distinct parent entities where the grand child entity contains a property of a specific value. So long as only one of the grandchildren of a specific parent contain the ...

73. Ejb3Configuration.addPackage() does not find entities.    forum.hibernate.org

Ejb3Configuration ejbConf = new Ejb3Configuration(); ejbConf.configure("TestPU", null); ejbConf.addPackage("org.jboss.jawabot.irc.ent"); ejbConf.addPackage("org.jboss.jawabot.irc.model"); ...

76. Hibernate doesn't seem to be inserting entities in order    forum.hibernate.org

Hi there. I have a tree of hibernate objects - it looks something like A -> multiple B's -> multiple C's -> Multiple D's There are times when I create an A, add a B to it, add some C's to B, and then add a D to each C. Then I do session.save(A). This works fine in MySQL, but trying ...

77. entity's table name for straight SQL query    forum.hibernate.org

I'm writing a stad-alone (SWT) application using Hibernate 2.1 + Spring framework 1.0.2. DB is MySQL Server. What I want to do is a "massive" delete of some table's rows. I know that in hibernate I do not have to use session.delete(Collection) because this will try to incarnate all table rows, then delete each single row from the table: this is ...

78. Entities in group by    forum.hibernate.org

Newbie Joined: Tue Sep 07, 2004 4:58 am Posts: 2 In the Hibernate docs at http://www.hibernate.org/hib_docs/reference/en/html/queryhql.html#queryhql-aggregation they show a query like this Code: select cat, count( elements(cat.kittens) ) from eg.Cat cat group by cat However, when I try a query like this (I'm using the hibern8ide to test queries): Code: select composer, count(elements(composer.children)) from Composer as composer group by composer I ...

79. No variable DISTINCT_ROOT_ENTITY defined    forum.hibernate.org

I'm using Hibernate 2.1 with JDK 1.3 ... When I compile a java file with the following line : criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY); I get the following error : No variable DISTINCT_ROOT_ENTITY defined in interface net.sf.hibernate.Criteria. criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY); Sure enough I peruse the Hibernate 2.1 code and the variable is not defined? What gives? Thanks. em

80. Prefetch entities using session.find    forum.hibernate.org

81. Basic Query Question with multiple entities    forum.hibernate.org

I have a question which I think should be quite easy to answer. I have looked everywhere for an answer and cannot seem to be able to find it partly I am guessing because I do not know the best way to ask the question. I have two entities, a family and a camper which families can have many of. I ...

82. Deleting entities with the Query API and MySQL 4.1.9    forum.hibernate.org

Hi, I am using Hibernate3 and MySQL 4.1.9 Professional. I wanted to delete an entity with the Query API: Query q = sessionFactory.createQuery("delete Entity where id=?"); ... return q.executeUpdate(); However, when executing this, I get a syntax error from MySQL. I pasted the generated SQL and used in another database client and still got the same error. It seems that MySQL ...

83. got the Unkonw entity error. using Native SQL Query    forum.hibernate.org

Hi I have a question to use native sql query in hibernate. Is the entity object specified in the native sql query required as the object mapping to the database table ? For example, Query = session.createSQLQuery(sql).addEntity("user", User.class); Must the User.class be the entity class that maps to the database table ? Can user object be any dynamic class type that ...

84. HQL - querying against entity collection    forum.hibernate.org

Hi. Here's my scenario. *Class Flavour - String: name *Interface Publishable *Interface Topic - extends Publishable - Collection: Flavour objects *Class DefaultTopic implements Topic *Class Book - Collection: Publishable objects Now I would like to have a Hibernate query where given a collection of Flavour objects, I find all Books which contain one or more Publishables of type Topic, which in ...

85. Entity class required in createSQLQuery???    forum.hibernate.org

My SQL Query is: select Q1.paAmount, Q2.pAmount From (select sum(pa.amount) paAmount,pa.BookingID paBookingid from package_acct pa, Groups g , Person_Group pg where .... group by pa.BookingID )Q1 Inner Join (SELECT sum(p.amount) pAmount, p.BookingID pbookingid FROM `payments` p where p.ispaid=1 group by p.BookingID )Q2 on Q1.paBookingid=Q2.pBookingID So I'm selecting on results of 2 other selects innerjoin.It works in mysql. I tried to use ...

86. Query by example returning wrong entities    forum.hibernate.org

When querying for orders, the collection returned is a collection of customers, even though when the criteria is created it it is told that we want Orders. This worked under hibernate 2, and stopped working after upgrading. Example exampleOrd = Example.create(ord).excludeZeroes().enableLike(MatchMode.ANYWHERE)..ignoreCase(); Example exampleCust = exampleCust = Example.create(cust).excludeZeroes().enableLike(MatchMode.ANYWHERE).ignoreCase(); Criteria x = session.createCriteria(Order.class); x.add(exampleOrd); x.createCriteria("customer").add(exampleCust); List orders = x.list(); This returns a List ...

87. Odd behaivor with Criteria.DISTINCT_ROOT_ENTITY    forum.hibernate.org

88. Projections.distinct(?????). Getting the right entity.    forum.hibernate.org

Either I am way out of tone or no one has an answer.. I'll bet for the former. I any case.. I am really interested about finding a way around this. I am willing to submit a patch and in fact I already checked out the code and was looking into the posibility of adding a new constructor to Distinct with ...

89. Criteria mixing projection and entity    forum.hibernate.org

Is there any way I can create a Criteria query that return an Entity and a projection at the same time? I want to retrieve an Entity list, and also include a specially calculated field for each one. The special field uses a custom function, which takes a parameter. Adding projections seems to force it into projection mode, and i can't ...

90. Criteria API and distinct entities    forum.hibernate.org

Hibernate version: 3.1 My current problem is that I have a query builder that uses the Criteria API to construct a query based on user input. My Criteria query joins to several other tables and specifies a max results. An example of a typical query in HQL that is impossible with the Criteria API is: Code: Query query = session.createQuery( "select ...

91. SQLQuery, sql-query leads to Unknown entity....why?    forum.hibernate.org

Need help with Hibernate? Read this first: http://www.hibernate.org/ForumMailingli ... AskForHelp I apologize for sounding dense here. I am very new, but, I have read, and read and read. I downloaded the caveatemptor sample. I have downloaded the latest hibernate. I have HQL working fine, and Criteria queries working fine. But I have a nasty union query that in my limited knowledge ...

92. Returning a non-entity from a named query, return-scalar,etc    forum.hibernate.org

Hibernate version: 3.1.2 I want to return a non-entity from a named query. That is, the returned objects from a named query are non-entities in the sense that I do not need to persist them. That is because, the named query does an aggregate function (e.g. select sum(), etc... ) However, I am not sure on how to go about this. ...

93. Query selecting entity property and joining on collection    forum.hibernate.org

Page 1 of 1 [ 1 post ] Previous topic | Next topic Author Message doublei2rd Post subject: Query selecting entity property and joining on collection Posted: Wed Mar 22, 2006 5:25 pm Newbie Joined: Wed Mar 22, 2006 4:48 pm Posts: 1 Location: Nebraska, USA I have an HQL statement ...

94. HQL, subqueries and entity params    forum.hibernate.org

Hi there, I'm having a small but annoying issue with HQL, subqueries and passing in an entity object as query parameter. Suppose I have two classes: User and Role, where a user points to a set of roles. Given a specific role I would now like to find all users that have that role assigned. I would expect the following code ...

95. How to check the reference count for an entity    forum.hibernate.org

Hi, I have an entity A that is referenced by several entity types - lets say B, C and D. I want to enable or disable the delete operation for A if it is referenced by other entities. Is there a light-weight way to do it? I mean, is there a way to know the reference count for entity A without ...

96. Criteria, Projection and select root entity    forum.hibernate.org

no, unfortunately this wont work since Proectsions.property is looking for mapped properties and not alias -> i will get some thing like "could not resolve property car in class Car". i tried the HQL version (select c, max(c.price) from Car c) and this does not work because of some troubles in the group by clause (not in agregate function or groub ...

97. Member collection of an entity has duplicates after query    forum.hibernate.org

Hibernate version: Hibernate 3.1.1 Hibernate Annotations 3.1 beta8 This is related to a previous problem i posted. http://forum.hibernate.org/viewtopic.php?t=960677 I have defined 5 classes using annotations as follows. Note that the following members are eager fetched: 1. contactNumbers of the Person class 2. cards of the Membership class Code: @Entity public class ContactNumber { @NotNull ...

98. selecting only few columns from entity    forum.hibernate.org

99. DISTINCT_ROOT_ENTITY with projections query cache problems    forum.hibernate.org

Hello all iam trying to execute a simple Criteria Query the query is as follows DetachedCriteria detachedCriteria = DetachedCriteria.forClass(MyClass.class); detachedCriteria.add(Restrictions.lt("day", new Date())); detachedCriteria.add(Restrictions.eq("contentType", "xyz")); detachedCriteria.createAlias("userContent", "userContent"); detachedCriteria.setProjection(Projections.projectionList() .add(Projections.alias(Projections.sum("count"),"sumAlias")) .add(Projections.groupProperty("userContent")) ).addOrder(Order.desc("sumAlias")); detachedCriteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY); This query translates to the following pseudo SQL "Select sum(count),content_id from ....group by Content_id order by sum(count)" when i run this with the query cache off it works fine and ...

100. Criteria Queries: Get entity and additional columns?    forum.hibernate.org

Is there a way, using criteria queries to extract an entity as well as additional columns associated with that entity? I'm using Postgres GIS queries to determine the distance of an entity, but I can't seem to get criteria queries to do what I want. If I use native SQL, I can do this: Code: session.createSQL("select {myentity.*}, distance(the_geom, MakePoint(...)) as distance ...