query « Field « JPA Q&A





1. Field's value of native query in JPA    stackoverflow.com

How to get value of some fields in a native query (JPA)? For example I want to get name and age of customer table:

Query q = em.createNativeQuery("SELECT name,age FROM customer WHERE id=...");
Note: ...

2. Hibernate querying on fields that do not exist in table anymore    stackoverflow.com

I have an entity that has a many to one mapping to another entity. Here is the mapping:

@JoinColumn(name = "user_id", referencedColumnName = "id")
 @ManyToOne 
private User user;
In the object (and table) ...

3. query only certain fields    forum.hibernate.org

Hallo, I've two classes Class A and Class B, both mapped bidirectional. I would like run a query for Class A, which select only certain fields with an appropriate constructor in Class A. But this ends up with an "Unable to locate appropriate constructor on class" Exception. the query looks like this: select new hibernate.City(city.idCity, city.name, c) from City as city ...

4. Query CSV value in field    forum.hibernate.org

I am working with a database that has multiple values stored as CSV in a varchar field such as: value1,value2,value3 or with spaces value1, value2, value3 Is there an expression in HQL that I can employ so that I can build queries like: select * from mytable where 'value2' in some_exp(csvfield) I'd prefer not to use LIKE because of false positives, ...

5. Loader Query with Additional Fields    forum.hibernate.org

6. Recommended practice for querying only some fields for objs.    forum.hibernate.org

I have a situation where I am loading a HTML page which lists many rows in a table. Each row represents an object called Schedule. I use Hibernate to manage persisting Schedule objects. Each Schedule has a Set collection and other String properties. On my HTML table I only want to list 2 properties and the COUNT of the internal Set ...

7. Strange query generated for object with calculated field    forum.hibernate.org

I have an Object that has a calculated field, when I try to list another object that references that object, hibernate generates an strange query, he tries to generate the code for calculating that field and this results in an wrong query. Does anybody knows what I am doing wrong? I am going to post my query code (I tried both ...

8. Query by example not using all fields    forum.hibernate.org

Author Message clajoie Post subject: Query by example not using all fields Posted: Sun Oct 17, 2004 12:59 pm Beginner Joined: Sun Oct 03, 2004 8:50 am Posts: 32 Location: McLean, VA I'm seeing what I think is odd behavior when attempting to do a query by example. The example object has two fields populated, a user id field ...

9. Query object by byte[] field    forum.hibernate.org

Hello, I'm trying to run a simple hql which searches by a byte[] field : "from Ci c where c.refId=?" but query does not return saved object. The Ci object is stored before with the refId attribute set to (new byte[]{1,2,3}) value. When the same refId value is used in hql the object is not returned. The hql is invoked by ...





10. Querying on non-accessor fields (ie, methods)    forum.hibernate.org

Querying in O/R Mappers I'm confused about performing queries with O/R Mappers, when properties don't map directly to database fields. Cases like: * calculated fields ( eg person.getAgeOn(today) -> method returns result of calculation, not simple accessor) * different subclasses implement field differently (some may store it directly, some may calculate it) * Methods like getZipCode() { return getAddress().getZipCode(); } which ...

12. Exclude one field in query    forum.hibernate.org

Hello all, i want to exclude only on field from a query, how would i do that? The problem with this is that sometimes i want the field to be included (if i specify a value for that field) and sometimes i don't want that field to be included (when there is no value specified for that field or it is ...

13. Restrincting fields in a query    forum.hibernate.org

Newbie Joined: Wed May 07, 2008 12:13 pm Posts: 8 Hi all, happy new Year!!!!! I have the follow question: I have a table with 17columns and there's a list where I just wanna show a table fraction like 10 fields (like a summary table) Then I created a entity manager native query selecting just 13 fields, but when the query ...