value « ID « JPA Q&A





1. get values with max id    forum.hibernate.org

hi all, I'm trying to retrieve of some hotels from the database with max(id). say the table is as follows: Id Hotel Year Month values 1 3 2010 5 8 2 2 2010 6 10 3 4 2011 8 20 4 3 2011 3 16 5 1 2011 4 15 6 4 2011 8 23 7 3 2011 3 31 So ...

2. Inert into User (name, pass, id) values (?, password(?), id)    forum.hibernate.org

I'm a newbee of Hibernate.. I create the User Table. ----------------------------------------------------- create table User ( name char(8) not null, pass char(30) not null, id char(8) not null, primary key(id) ); ----------------------------------------------------- Persistent Object is the following. ----------------------------------------------------- public User { private name, pass,id; public String getName(){}; public String getPass(){}; public String getId(){}; public void setName(String name){}; public void setPass(String pass){}; public ...

3. howto use id_value for unsaved-value    forum.hibernate.org

4. usage of unsaved-value="ID_VALUE"?    forum.hibernate.org

Hi I try to use unsaved-value="id_value" and it gives the error below? any ideas? P.S the mapping is included below Mapping spec from the manual (5) [i] [B]ERROR[B] net.sf.hibernate.MappingException: Could not parse unsaved-value: id_value at net.sf.hibernate.persister.AbstractEntityPersister.(AbstractEntityPersister.java:515) at net.sf.hibernate.persister.EntityPersister.(EntityPersister.java:623) at net.sf.hibernate.impl.SessionFactoryImpl.(SessionFactoryImpl.java:203) at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:594) at HibernateDBConnection.initialiseSessions(HibernateDBConnection.java:44) at HibernateDBConnection.getSession(HibernateDBConnection.java:66) at XMLTest.getQuery(XMLTest.java:44) ...

5. unsaved-value of an assigned id    forum.hibernate.org

I think I really have problems in understanding the usage of unsaved-value. class X ... id .... unsaved-value = "any/none/null.." generator = "assigned" class Y id ... unsaved-value = "null" generator = "sequence" many-to-one = x cascade= "save-update" I really have doubts to solve the unsaved-value problem for the assigned id. if I used the generator = " sequence" for X ...

6. Start value for ID generation    forum.hibernate.org

michael wrote: I think there is a way to specify the autoincrement start value when creating the table ... check the mysql manual Thanks, yes that should work. In our case though we're relying on hibernate's schema export function. Yes, could easily switch to using scripts but then there's one more thing to maintain whenever there's a schema change (though once ...

7. Wrong value of ID    forum.hibernate.org

I used Hibernate a wile and had no problem, but yesterday I was trying to do what I always do, nothing fancy but I'm getting a wrong value for ID. I have primitive class and mapping: Code: public class ServerUser{ private Long id; private Long creater; private Date created; ...

8. @Id and its unsaved-value    forum.hibernate.org

I am having problems with @Id and its unsaved-value. I would like the unsaved-value to default to something without an instance being created. But the code in UnsavedValueFactory.getUnsavedIdentifierValue seems to choose to try to instantiate an instance before it checks whether the @Id is of a primitive type: Code: if ( unsavedValue == null ) ...





10. Why ignore value of id?    forum.hibernate.org

...

11. Generating a value which depends on id    forum.hibernate.org

Hello, I came upon an interesting problem: I have a table, which has an id and depends_on_id columns. depends_on_id is constrained not to contain null values, and I map a class SomeClass to it. I use org.hibernate.id.enhanced.TableGenerator to generate the ids. The caveat is that the value of depends_on_id depends on the id generated - that is I need to know ...

12. id unsaved-value strategy UNDEFINED    forum.hibernate.org

Hello, In debug mod of the server I found a bug during the "saveOrUpdate" of an object Ventilation. The printed trace is "id unsaved-value strategy UNDEFINED". I manage to saveOrUpdate others objects but the mapping of their id was simple. I thing that the problem com from the mapping of the id of Ventilation. ====================== Mon fichier de mapping: -------------------------- Code: ...