1. Hibernate query: find equal objects stackoverflow.comI have a Hibernate class which has a reasonably complicated implementation of |
2. Creating a new object instance in hibernate using a sql query stackoverflow.comI am attempting to create an object in hibernate using a query, which will then be saved back to the table representing the class. Excerpt from hbm.xml file:
|
3. create object in hibernate select stackoverflow.comI have 2 classes:
in hql I want to select like this:
|
4. Hibernate query with criteria as an object coderanch.comHi Gene, I'm not sure what your object model looks like, so this may or may not be relevant ;-) It sounds as if you have an association within your Eventattendance class represented by another object and you want to query your results and restrict by some attribute in the associated class. I've added an example below which hopefully is similar ... |
5. same entitites from different JPA queries to be the same object instances coderanch.comHi. In my web application I use several different JPA queries to retrieve objects from database and populate my http session data structure. This includes list of cars, list of groups of cars and some other structures containing cars. Any car can be included in several different structures. For example the same car can be included in group G (as the ... |
6. Hibernate: Running a query using an object coderanch.comHi, I'm using Hibernate core 3.3.2.GA. Let's say I have this object ... @Entity @Table(name="tbl") public class MyObj implements Serializable { private String field1; private String field2; ... @Column(name="FIELD1") public String getField1() { return field1; } @Column(name="FIELD2") public String getField2() { return field2; } } Given an instance of the above object in which some fields are null and some are ... |
7. How to compose objects hierarchy using query forum.hibernate.org |
8. JOIN not working; too many SELECTs querying single object forum.hibernate.orgSession session = currentSession(); session.beginTransaction(); User user = (User)session.createQuery( "from User u, UserStatusType ust, UserRegion ur, " + " where u.user_id = ? AND u.userStatusType.id = ust.id AND u.region.id = ur.id") .setLong(0, 42L) ... |
9. Is there any way to find out if an object is outdated? forum.hibernate.orgThanks for the reply. What good would a version property to in this case? I mean once I load an object from the database it is cached in the persistence context. Every subsequent load would simply return this chached reference ... not a new (probably more recent) object. An example. A long running transaction. To get my point across lets say ... |
10. Query deos not retrive any objects forum.hibernate.orgHi, I have an object Coompany with an asociation to an object Compnay info. I want to perform a query in order to retrive objects from the table company which comply with a condition. For example. I want to retrive all the objects whos ids are "123". String var = "123"; Query q= ses.createQuery("FROM Company as comp WHERE comp.id = '"+var+"'"); ... |
11. Is it possible to query by Object? forum.hibernate.orgI'm not sure if I found the documentation on what you mentioned, what I did find was Criteria queries. I still did not find any examples on the following: I want to pass just the object(who's properties are set to match my criteria) and have the criteria built for me. This would be better than having to build the criteria by ... |
12. how to select an object without its parent forum.hibernate.orgHello, what is the best syntax to be used within a select if I want to load an object within a graph without its parents and children example: object A | | |* object B | | |* object C I wand to load via a select the object B without its A and C relationships. To avoid the C relationship, ... |
13. What is the fastest query to read a graph of objects forum.hibernate.orgWhen I use session.load(from A where A.id=?); Hibernate generates many select statements to get A, Bs, and Cs separately, which is not efficient. When I add "left join fetch" for B and C, Hibernate uses the same statement to get A, Bs, and Cs, but the query is slower that the previous one. My point is are there any guidelines for ... |
14. Scalar query and objects instances forum.hibernate.org |
15. How to not use Proxy for Object with HQL Query forum.hibernate.orgHi all, I have an HQL query: select db from Daughterboard db where db.scintillationFileNumber=? that when it didn't find a match used to throw an ObjectNotFoundException. Now however I have a proxy, so it waits until first used to throw a LazyInitializationException. Is there any way in the HQL to force the load, and make it eager? I could in my ... |
16. only one object but two selects forum.hibernate.orgHello, i have 3 classes 1. Baseobject 2. User 3. Room User and Room extends Baseobject In Baseobject is the native id of the objects, that runs fine. There are 3 tables for the 3 classes. Now i have a one to many between room and user with lazy = true but when i select a user, after that hibernate selects ... |
17. Partially populating object instance from a query forum.hibernate.orgIs there any built in mechanism to do a HQL query and return a List of partially populated object instances? For example, say if I have a Person class with firstName, lastName, dob, sex, height attributes. There may be a case where I only want to return the firstName and lastName fields for every Person, i.e. at this point in time ... |
18. Multiple objects in a HQL query forum.hibernate.orgHi, I've got a problem with a query in HQL when I select multiple objects. Sometimes, (and I don't know why) instead of getting in return of my query an array of Object[], I've only got the first object. Of course I can get my second object by my first one with the relation between them, but obviouly it's not my ... |
19. Finding all objects with forum.hibernate.orgConsider the classic Student -< Enrolment >- Course M-M relationship. Im using |
20. How to query for unreferenced objects? forum.hibernate.orgThere are several ways to phrase this question, and I think I know the answer, but here goes anyway. I have a two-way many-to-many mapping: Code: |
21. Select most recent object forum.hibernate.orgI have a hibernate object heirarchy in a table named "entry". All entries have a dateCreated field. I would like to select entries based on several parameters, one of which is that the entry should be the most recent of those that match the rest of the parameters. The best I've been able to do is get a dateCreated-ordered list of ... |
22. Creating an object in select forum.hibernate.orgHi All, I am trying to do something like "select new Family(mother, mate, offspr)" from the Hibernate 2.1.2 Reference document on page 79. I can get it to create a class if I only have Strings, Integers, and Longs, but as soon as I try to use a Timestamp I keep getting: net.sf.hibernate.PropertyNotFoundException: no appropriate constructor in class: com.nameprotect.ba.dao.AlertSummary I have ... |
23. Is it possible to select multiple objects? forum.hibernate.orgHi, Is it allowed to select multiple kinds of objects in hsql, for example the following hsql: select usage.product.id usage.cpbr.testSite usage.cpbr.process.name from CPBasicRecordInfo as usage where usage.status = ? , where there are 3 kinds of objects selected usage.product.id usage.cpbr.testSite usage.cpbr.process.name. If this is allowed, how to retrieve the returned list? Regards, Rice |
24. Order By on Sub Objects using Criteria forum.hibernate.orgHi all, I am trying to perform an Order by using the Criteria API on sub Classes of the initial Class the Criteria was created on. Code: public List listApplicationLands(Long clasCaseKey) throws PersistenceLayerException { ClasCriteria criteria = null; try { ... |
25. Criteria Query- double selects, overwrites object graph forum.hibernate.orgI have an object mapped like this; Code: |
26. Find not referenced Objects forum.hibernate.orgHello, ich have a n:m Relation between Person and Role, with an intermediate Class Member. (2 one-to-many) How can I fetch all Roles where a Person is NOT a Member? Regards Christian ---- Database Postgresql Hibernate 2.1.6 Tables: create table PERSON ( PERSON_ID int8 not null, name varchar(255), primary key (PERSON_ID) ); create table MEMBER ( MEMBER_ID int8 not null, PERSON_ID ... |
27. Find objects forum.hibernate.orgNewbie Joined: Mon Aug 30, 2004 6:25 am Posts: 7 What sql expression need I write to view List of objects? Hibernate version: 2.1 Mapping documents: |
28. Using objects directly vs HQL Query forum.hibernate.orgI'm having a bit of a problem coming up with an HQL query, and wondered if someone could help me.... In my domain model, I have a Topic, User and Subscription. A Topic has a set of Subscriptions against it, and each Subscription belongs to a User. A User can have many simultaneous Subscriptions and additionally has the concept of a ... |
29. Configuration object call order forum.hibernate.org |
30. Querying versioined objects forum.hibernate.orgSeems like max has misinterpret the "versioning" term - just like I did when new to Hibernate. It is not "versioning" as in "content management versioning" and the like where every change results in a new "revision" leaving the original in place. Sorry - have to implement this "revision history" mechanism yourself. Please get back to me when it's finished! ;) ... |
31. "View" object for join queries forum.hibernate.orgI've been trying to perform a join query using the named query feature of hibernate 2. The problem is that I've been doing it with two aliases defined in the named query, one for each of the tables that are being joined; this works fine, the only issue is that the Collection returned contains arrays of two elements (one for each ... |
32. Problem with the order that CGLIB uses to fill my object forum.hibernate.orgHi all! I'm using Hibernate3 and Im having a problem when Im loading an object with HQL. This object have a List in it and this list is set to fetch="join" and lazy="true". Using Eclipse debugger, when Hibernate retrieve my object it has a list in it with two elements, but when CGLIB puts values into my final object, the order ... |
33. Howto query objects they are not in many-to-many assoc forum.hibernate.org |
34. select java objects with no-SQL variable forum.hibernate.orgHello, I need construct select, when return java objects with constructor, but in constructor I want put some no-SQL variable, for example I have ViewClass: public class ViewClass { private Long id; private String name; private Timestamp date; boolean timeout; public ViewClass (Long id, String name, Timestamp date, long timeout) { this.id = id; this.name=name; this.date=date; if (timeout>date.getTime()) this.timeout=true; else this.timeout=false; ... |
35. "select new" w/the object created by the query hav forum.hibernate.orgHibernate version: 3.1 rc2 Name and version of the database you are using: Sybase ASE 12 Here's my problem: I'm trying to do a session.createQuery("select new myBean... but the hick is that one of the property of myBean is a set that will contain a mapped hibernate object (table2 objects). Here's an example: session.createQuery("select new myBean(table1.column1, table1.column2, table2) from table1 left ... |
36. Query by partially populated object forum.hibernate.orgHi Folks, I could have sworn there was a way to use a partially populated dao object to query the database. eg... Product p = new Product(); p.setAvailable(true); session.find(p); .. it returns all objects where available = true in the database. Am I crazy.. do I have to use a criteria query for this.. or is there a way to do ... |
37. SQL Queries and Objects forum.hibernate.orgHi I'm wondering if the following is possible... I have sql queries, that contain fields out of several tables. Not all columns from the tables are used. Therefore, the SELECT fields do not make up an existing Hibernate generated database Entity object, instead I want to be able to automatically populate a custom class, for example the following: Class Customer { ... |
38. populate a single object using multiple queries forum.hibernate.orgCan anyone recommend an approach for populating an object with multiple queries? An object that does not map directly to a table and cannot be completely populated with a single SQL statement. For example, if I have an object that contains the following. studentId studentName numCourses avgGrade lowGrade highGrade Assume that there is no way to return all this in one ... |
39. How to remove the existing ordering from a Criteria object. forum.hibernate.org |
40. Criteria Query does not work with coll. of dependent objects forum.hibernate.orgHi, I am experiensing a problem using Criteria Queries with a collection of dependent objects. I have an entity class EmailDialog that contains a collection of UserEmailDialog objects (field participants). UserEmailDialog is an association class that represents properties of an association between Users and EmailDialogs. Here is my mapping for class EmailDialog: |
41. select new Object in Hibernate3 forum.hibernate.org06/10/12 15:00:10 java.lang.NullPointerException 06/10/12 15:00:10 at java.lang.Class.forName0(Native Method) 06/10/12 15:00:10 at java.lang.Class.forName(Class.java:164) ... ... org.hibernate.QueryException: Incorrect query syntax [select new FisImpuestoDto(bi.codigoImpuesto, io.nombre, io.codigoFormulario) from gt.gob.sat.jfisat.jpista.backend.dto.FisBaImpuestoDto bi, gt.gob.sat.jfisat.jpista.backend.dto.FgImpuestoObligacion2Dto io where io.codigoImpObl = bi.codigoImpuesto and io.codigoTabla is not null and io.tipo = bi.tipo and io.tipo = 'I'] at org.hibernate.hql.classic.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:208) ... ... Caused by: java.lang.NullPointerException at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:164) |
42. Criteria object order by rand() forum.hibernate.org |
43. Query throws "object references unsaved transient insta forum.hibernate.orgIf the object you are retrieving hasnt been committed yet (in the same tx but not yet saved) or if it references a collection thats not saved it, the exception that you indicate below might appear. If you have any other unsaved objects in the same Transaction, consider saving those before calling the Query. |
44. Selection of objects with backreference forum.hibernate.orgNewbie Joined: Wed Mar 15, 2006 5:46 am Posts: 2 Hibernate version: 3.2.0 GA (JEMS Installer 1.2.0), 3.2.1 (JBoss 4.2.0CR1) Full stack trace of any exception that occurs: ClassNotFoundException: [Lorg.jboss.aop.Inteceptor Could not find marshaller for data type ('null'). Trying to load from server (from my memory) Name and version of the database you are using: MySQL 5.0.37, ConnectorJ 5.0.5 JDK 1.6.0 ... |
45. Typesafe Object in HQL Select forum.hibernate.orgPer the documentation in section 14.6 in hibernate docs: http://www.hibernate.org/hib_docs/v3/reference/en/html_single/#queryhql-select Quote: Code: select new Family(mother, mate, offspr) from DomesticCat as mother join mother.mate as mate left join mother.kittens as offspr assuming that the class Family has an appropriate constructor. Why does the constructor in this case has to public? This method in ReflectHelper ... |
46. PropertyAccessException when querying an object. forum.hibernate.orgjsmoorejr Post subject: Posted: Thu Sep 04, 2008 6:06 pm Newbie Joined: Thu Sep 04, 2008 5:57 pm Posts: 3 I am having a similar problem. I have DB rows that contain (null) in an Oracle Database. I am using java.lang.Float in my mapping file and in my java class. Still when I query the DB I get a ... |
47. Hibernate object query browser forum.hibernate.orgHello, There are quite a lot of database query browsers, including MySql Query Browser and the Hibernate Tools plugin for eclipse. However, these db query browser allow only to see relational tables, but they don't allow to see the objects instantiated from Hibernate. Is there an "object query browser" for Hibernate? e.g. I issue the HQL query "FROM Orders", gettimg a ... |
48. Too many selects for just retrieving a single object. forum.hibernate.orgWhen retrieving entity, hibernate first selects all primitive fields and ids for non-primitive fields in a select statement, then starting to select non-primitive fields using other statements. The problem is, if Class A has 100 non-primitive fields, then they will at least 100 statements used for only retriving a single A instance. Is there any way to optimize it to few ... |
49. Best practices for finding + removing references to objects? forum.hibernate.org |
50. Query objects using 'select * from ...', is it possible? forum.hibernate.orgHi, May be this is a simple question... but I'd searched for a while and found nothing about it. When you query for objects using HQL, for example "from Car c where c.year>?", Hibernate uses two SQL statements: * The very first one retrieves the Id's of the resulting records: SELECT CAR_ID FROM CARS WHERE CAR_YEAR>? * The second one retrieves ... |
51. How to find Dirty Objects? forum.hibernate.orgHi All, I have got 2 entites in the parent child relationship. Whenever parent is persisted, I need to check for its dirty childs. This is because, I need to do some custom processing before dirty objects can be persisted. Is there any way through which I can determine before hand if an object is Dirty or not. It will be ... |
52. too many queries - object graph forum.hibernate.orgHi, I am designing one survey system. Following is the details: - One survey can have many questionpages - One questionpage can have many questionsections - One questionsection can have many questions - One question can have many answers - One answer can have many features - One feature can have many rules I am using many-to-one relationship and keeping bags ... |
53. Hibernate Object Adhoc Query Builder? forum.hibernate.orgHi, Throwing out a shout in the dark, but wondering if anyone has seen a project that essentially is an "OQL AdHoc Query Builder". Basically, I'm looking for a web app that exposes all mapped Hibernate Objects, and then allows you to continuous "expand" the criteria based on children, properties, etc. It seems that since a schema is mapped, and an ... |
54. query to get many-to-many objects forum.hibernate.orgHi, I'm new to hibernate and I'm trying to do some basic stuff... I have countries and partners. Moreover countries have many partners and this association is defined by means of the table partner_in_country. here is how I mapped the classes: Country Code: |
55. Hibernate query OK but object received incorrect forums.oracle.comThis works fine. we get a list of object (with one DemandIndex) but when the object gets back to Tomcat, its parameters are all unset... ie: List |