class « Query « JPA Q&A





1. JPA/Hibernate query with class name?    stackoverflow.com

In this example com.test.Cat extends com.test.Animal and there is no field DB in CAT table of com.test.Cat explicitly defining its type (it wasn't me). When I query my animals from DB I ...

2. Hibernate setParamater a class    stackoverflow.com

I am new to Hibernate. I want to create a public Object getById(Class class,long id) function. I tried creating query like: from :nameEntity where id= :id but I'm facing problems when ...

3. storing currently selected payment info in Customer class    stackoverflow.com

I need to store a customer's currently selected payment info ,so that this info can be used in processing a purchase.Customer can have many credit cards.So I modelled it as a ...

4. (Hibernate Tutorial chap 1)ServletException: Wrapper cannot find servlet class    coderanch.com

Hi there, i am about to get a .war archive running on a tomcat server(Apache Tomcat/5.0.28). The jvm i use is: 1.5.0_03-b07 As described in the docu i placed the archive in the webapps folder and launched tomcat. So far everything went fine. I can open the default Tomcat page on localhost. But when i tried to open my new app ...

7. Hibernate incorrect replacement of Class in Named Query    coderanch.com

I have two java classes, CurrentData and HistoricData, where HistoricData extends CurrentData. There is no relationship implied or intended between the hibernate mappings, the tables are almost identical, but where one has a currentFkId column the other has a historicFkId column. While this might be a weird situation, I don't believe it should break any of Hibernate's assumptions. However, we have ...

8. Cannot find AnnotaionConfiguration class    forum.hibernate.org

9. Cannot find AnnotaionConfiguration class    forum.hibernate.org





10. Unnecessary joines when doing a select count on parent class    forum.hibernate.org

Beginner Joined: Tue Sep 08, 2009 9:49 am Posts: 23 Hi, I have three tables, video, photo and content. video and photo are sub classes of content. Now I want to select the count of all content items using a criteria: Code: public int findContentCount() { ...

11. How to only query root class using Inhertiance ?    forum.hibernate.org

13. Selecting a sub-class in a super-class collection    forum.hibernate.org

@Entity @Table(name = "A_CLASS") public class AClass implements Serializable { private static final long serialVersionUID = 6940459502248157282L; @Id @Column(name = "A_ID", precision = 22, scale = 0) private Long id; @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "rgd") ...

14. How to select base class?    forum.hibernate.org

Hello, everybody! I have simple class hierarchy. @MappedSuperclass class Base { @Id int id; @OneToMany Set other; } @Entity class MyClass extends Base { String prop1; String prop2; String prop3; } When I select MyClass everything is ok. But in some cases I don't need properties prop1,prop2 prop3, so I want to select Base class only. Something like session.createQuery("from Base where ...

15. Query with multiple classes - how?    forum.hibernate.org

16. finding the classname when using proxies?    forum.hibernate.org

hi- Im sure there is some simple way around this, but I can't figure it out. Basically, I want to find the className of an object dynamically, and use the following: object.getClass().getName()... This works normally of course, but when using proxies, the name returned is not what you would expect. Is there any way around this issue when using proxies? Thanks! ...





18. Use of the Select Class of Hibernate    forum.hibernate.org

19. what's wrong with my code using "select new ClassName(.    forum.hibernate.org

Changes in version 2.1.2 (4.2.2004) * queries with "select new" now cacheable =============================== my code: ---------------------------------------- Query query=ss.createQuery( select new ClassName({tableName}.x}) from TableName as {tableName} where ... ); my code break on Iterator iter = query.list().iterator(); error message is about something wrong on sql server........... ================================ what's wrong with my code using "select new ClassName(... /** * Demonstrates HQL projection/aggregation */ ...

20. Full Package + Class name in Query    forum.hibernate.org

net.sf.hibernate.QueryException: in expected: mo [FROM MyObject mo WHERE mo.name='test'] at net.sf.hibernate.hql.FromParser.token(FromParser.java:102) at net.sf.hibernate.hql.ClauseParser.token(ClauseParser.java:87) at net.sf.hibernate.hql.PreprocessingParser.token(PreprocessingParser.java:123) at net.sf.hibernate.hql.ParserHelper.parse(ParserHelper.java:29) at net.sf.hibernate.hql.QueryTranslator.compile(QueryTranslator.java:149) ...

21. Order-by on a joined class    forum.hibernate.org

Hi, I have the problem of ordering a set using a property defined in a joined class (Hibernate 2.1.3). Code: ... ...

22. Criteria, double class in clause    forum.hibernate.org

Newbie Joined: Wed Jul 28, 2004 8:03 am Posts: 8 Location: Porto Alegre - Brazil toastchee wrote: Can you post the src of br.com.ag2.quatromais.vo.Compromisso ? Sure! Code: /** identifier field */ private Integer codCompromisso; /** persistent field */ private Date dthInicioCompromisso; /** persistent field */ ...

23. restricting finding objects to just that class    forum.hibernate.org

So in all the documentation and examples, i've seen that you can do a find with a hql clause "from myClass" and it gets all inherited objects as well (very cool). But lets say i have two classes myClass and myInherited extends myClass And in a particlar case i ONLY want objects of type myClass and NO objects of type myInherited. ...

24. can I refer to class constants in a query?    forum.hibernate.org

25. HQL query in dynamci class ? Help me figure this out....    forum.hibernate.org

Newbie Joined: Mon Dec 13, 2004 2:32 am Posts: 8 Hi Everybody, I am farily new to Hibernate trying to evaluate the dynamic-class concepts which which ware planning to use in our future projects. I am really impressed with this new feature, so far i have been able to use the dynamic class concept and perform the following operation, 1. Persist ...

26. Hibernate query indicates to a wrong table (class)    forum.hibernate.org

hi, id like to receive data via HQL but the query does not select data from the given class. Hibernate tries to select data from a subclass but this subclass is not mapped as a subclass. (no possibility to mix subclass and joined subclass) I would like to select data from class Asset but hibernate tries to get data from class ...

27. Selecting a superclass only    forum.hibernate.org

Hello I have the following mapping. An employee is a Person. I wish to select(Using HQL) only those who are persons and not employees. Here is my mapping file Code:

28. Class with where clause    forum.hibernate.org

Hibernate version:3 rc1 Code: ...

29. cannot make hibernate to translate class query correctly    forum.hibernate.org

I have three classes, A, B and C. B and C inherit from A. I try to send a query to only obtain subclass B like this: SELECT A as a FROM A where a.class = .B When Hibernate traduces it to propietary SQL it does transformations to get a "discriminator" for the joined subclass, it assigns "0" for A, "1" ...

31. Hibernate getting query class confused    forum.hibernate.org

Hi there, I'm encountering an interesting problem where Hibernate is selecting from a different class to that supplied to the query. I've tried this out on all 3.0.x versions (up to 3.0.5), and with both HQL and Criteria queries. I have a table called OFFICE. I also have a view called V_USER_OFFICES, which provides a restricted list of office IDs that ...

32. could not find PropertyAccessor class: public    forum.hibernate.org

Hi Im falling from one pitfall to next. I get following error during deploying to Jboss 4.0.2: 2005-07-01 22:54:18,940 INFO [org.hibernate.jmx.HibernateServiceMBean] Could not build SessionFactory using the MBean classpath - will try again using client classpath: could not find PropertyAccessor class: public 2005-07-01 22:54:18,940 DEBUG [org.hibernate.jmx.HibernateServiceMBean] Error was org.hibernate.MappingException: could not find PropertyAccessor class: public at org.hibernate.property.PropertyAccessorFactory.resolveCustomAccessor(PropertyAccessorFactory.java:103) Please tell me, if ...

33. Query / Root classes not fetched    forum.hibernate.org

34. Query in a table per class hierarchy?    forum.hibernate.org

I'm attempting to make a simple category system, consisting of category classes containing subcategory classes. I've mapped it as a table per class hierarchy. Where Category is the parent and SubCategory is the subclass. The problem for me comes when I get all the Category classes. It loads the SubCategory classes as well. I understand this is how Hibernate works and ...

35. Selecting only the parent class from HQL    forum.hibernate.org

Need help with Hibernate? Read this first: http://www.hibernate.org/ForumMailingli ... AskForHelp Hibernate version: 3.0.5 Mapping documents: Code: ...

36. can not find hibernate.jndi.class when buildSessionFactory()    forum.hibernate.org

Hi, I use JDK1.4.1, hibernate-3.1 In hibernate.properties, I set: hibernate.session_factory_name hibernate/session_factory hibernate.jndi.class com.sun.jndi.fscontext.RefFSContextFactory hibernate.jndi.url file:/ In hibernate.cfg.xml: statement sessionFactory = new Configuration().configure().buildSessionFactory(); throws exceptions says class com.sun.jndi.fscontext.RefFSContextFactory could not be found. Could anyone tell me which hibernate.jndi.class and hibernate.jndi.url should I specifiy? There are two environments: one is JDK1.4+hibernate-3.1 and one is JDK1.4+hibernate-3.1+tomcat5.0 Thanks in advance.

37. Get objects from superclass using a simple query    forum.hibernate.org

If you actually mean superclass, then the objects of the child class are of the superclass. Just cast the child objects to the superclass, if that's all you want. If you don't understand the concept, there are a lot of good books out there on object orientation. If you're misusing the terminology and mean an object and its nested objects, then ...

38. Query possible: collection contains an instance of a class?    forum.hibernate.org

Entity A has ManyToMany relationship with Entity B. Class B is the base class for a class hierarchy, and C is a subclass of B in the class hierarchy. class A { List getBList(); } Query: get all A(s) that have a instance of C. Note that: C is a subclass of B. It is OO. If A has an instances ...

39. hot to configure cglib to find classes in app serv classpath    forum.hibernate.org

Hi, I'm using Hibernate 3 and my persisted classes are located in the shared classloader of Tomcat, while the cglib jar is in the WEB-INF/lib of my webapp. It looks like I'm getting this error org.hibernate.HibernateException: CGLIB Enhancement failed: org.gridsphere.services.core.security.role.PortletRole at org.hibernate.proxy.CGLIBLazyInitializer.getProxyFactory(CGLIBLazyInitializer.java:132) as a result. Is there some way in Hobernate props file to tell CGLIB to use the default webapp ...

40. Transformers, "select new" HQL, LightWeight Class.    forum.hibernate.org

Trying to develop the best way to implement the following... I have Clob column in a database table that I am using for a keyword search. I don't need this column instantiated in the POJO and returned the the UI, only for the search. I got around this for the search by using dynamic instatiation with a select new (....) http://forum.hibernate.org/viewtopic.php?t=963141&highlight=. ...

41. Query using more than one class?    forum.hibernate.org

42. Query translator factory class    forum.hibernate.org

Hi, Hibernate configuration issue: While using 3.1RC2, my configuration for hibernate.query.factory_class was org.hibernate.hql.ast.ASTQueryTranslatorFactory. If I leave it at that I get a "(HibernateUtil.java:23) - Hibernate Initial SessionFactory creation failed.". If I change it to org.hibernate.hql.classic.ClassicQueryTranslatorFactory it works. Any ideas why this is happenning? thx Hibernate version: Migrating from 3.1RC2 to 3.2 Mapping documents: Code between sessionFactory.openSession() and session.close(): Full stack trace ...

43. Query on superclass not working    forum.hibernate.org

Newbie Joined: Wed Dec 06, 2006 4:04 pm Posts: 8 Location: New Hampshire I am running Hibernate 3.2.1 against an Oracle 10G database using annotations in my java classes (no xml). Could you look at this and tell me if I have something set up wrong? I have a superclass SUPER and three subclasses SUB1, SUB2, SUB3. My classes look like ...

45. table per class hierarchy: 2nd select seems to be redundant    forum.hibernate.org

@Entity @Table(name = "account") @Inheritance(strategy = InheritanceType.SINGLE_TABLE) @DiscriminatorColumn(name = "type") public abstract class BaseAccountPojo { @Id @GeneratedValue @Column(name = "account_id") public Long accountId; } @Entity @DiscriminatorValue("cust") public class CustAccountPojo extends BaseAccountPojo { @OneToOne @PrimaryKeyJoinColumn public CreditCardPojo creditCard; ...

46. How do I find JNDI URL and CLASS?    forum.hibernate.org

47. HQL for querying in single table for class hierarchy mode    forum.hibernate.org

@Entity @Inheritance(strategy=InheritanceType.SINGLE_TABLE) @DiscriminatorColumn(name="type", discriminatorType=DiscriminatorType.STRING) public class Lov extends BaseEntity { private String name; public String getName() { return this.name; } public void setName(String name) { this.name = name; } }

50. select concrete class name in query is possible?    forum.hibernate.org

It's a frequent requirement to select (id, name) tuples into a list in order to, for example, construct a list of URLs, where the name will be the link string and the id will be a query string parameter. This is easy enough to do in HQL. I went one step further and created an object with an id and a ...