From: <leg...@at...> - 2003-12-08 10:56:41
|
The following comment has been added to this issue: Author: Hunter Kelly Created: Mon, 8 Dec 2003 4:56 AM Body: Here is the output when run: cd /home/retnuh/stuff/hibernate/cvs/hibernate-2.1/eg1/test/ ant -find build.xml -emacs eg1 Searching for build.xml ... Buildfile: /home/retnuh/stuff/hibernate/cvs/hibernate-2.1/build.xml Could not load definitions from resource clovertasks. It could not be found. eg1: Compiling 1 source file to /home/retnuh/stuff/hibernate/cvs/hibernate-2.1/eg1 remember to place your JDBC driver in the lib directory 08-Dec-2003 10:55:30 net.sf.hibernate.cfg.Environment <clinit> INFO: Hibernate 2.1 rc1 08-Dec-2003 10:55:30 net.sf.hibernate.cfg.Environment <clinit> INFO: loaded properties from resource hibernate.properties: {hibernate.connection.driver_class=com.mysql.jdbc.Driver, hibernate.cglib.use_reflection_optimizer=true, hibernate.cache.provider_class=net.sf.hibernate.cache.HashtableCacheProvider, hibernate.max_fetch_depth=1, hibernate.dialect=net.sf.hibernate.dialect.MySQLDialect, hibernate.jdbc.use_streams_for_binary=true, hibernate.jdbc.batch_size=0, hibernate.query.substitutions=true 1, false 0, yes 'Y', no 'N', hibernate.proxool.pool_alias=pool1, hibernate.connection.username=root, hibernate.connection.url=jdbc:mysql:///thing, hibernate.connection.password=root, hibernate.connection.pool_size=1} 08-Dec-2003 10:55:30 net.sf.hibernate.cfg.Environment <clinit> INFO: using java.io streams to persist binary types 08-Dec-2003 10:55:30 net.sf.hibernate.cfg.Environment <clinit> INFO: using CGLIB reflection optimizer 08-Dec-2003 10:55:30 net.sf.hibernate.cfg.Configuration configure INFO: configuring from resource: /hibernate.cfg.xml 08-Dec-2003 10:55:30 net.sf.hibernate.cfg.Configuration getConfigurationInputStream INFO: Configuration resource: /hibernate.cfg.xml 08-Dec-2003 10:55:30 net.sf.hibernate.cfg.Configuration addResource INFO: Mapping resource: Thing.hbm.xml 08-Dec-2003 10:55:30 net.sf.hibernate.cfg.Binder bindRootClass INFO: Mapping class: test.Thing -> thing 08-Dec-2003 10:55:30 net.sf.hibernate.cfg.Binder bindRootClass INFO: Mapping class: test.UUIDThing -> uuidthing 08-Dec-2003 10:55:30 net.sf.hibernate.cfg.Binder bindRootClass INFO: Mapping class: test.IntThing -> otherthing 08-Dec-2003 10:55:30 net.sf.hibernate.cfg.Configuration doConfigure INFO: Configured SessionFactory: null 08-Dec-2003 10:55:30 net.sf.hibernate.cfg.Configuration secondPassCompile INFO: processing one-to-many association mappings 08-Dec-2003 10:55:30 net.sf.hibernate.cfg.Configuration secondPassCompile INFO: processing one-to-one association property references 08-Dec-2003 10:55:30 net.sf.hibernate.cfg.Configuration secondPassCompile INFO: processing foreign key constraints 08-Dec-2003 10:55:31 net.sf.hibernate.dialect.Dialect <init> INFO: Using dialect: net.sf.hibernate.dialect.MySQLDialect 08-Dec-2003 10:55:31 net.sf.hibernate.cfg.SettingsFactory buildSettings INFO: Maximim outer join fetch depth: 1 08-Dec-2003 10:55:31 net.sf.hibernate.cfg.SettingsFactory buildSettings INFO: Use outer join fetching: true 08-Dec-2003 10:55:31 net.sf.hibernate.connection.DriverManagerConnectionProvider configure INFO: Using Hibernate built-in connection pool (not for production use!) 08-Dec-2003 10:55:31 net.sf.hibernate.connection.DriverManagerConnectionProvider configure INFO: Hibernate connection pool size: 1 08-Dec-2003 10:55:31 net.sf.hibernate.connection.DriverManagerConnectionProvider configure INFO: using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql:///thing 08-Dec-2003 10:55:31 net.sf.hibernate.connection.DriverManagerConnectionProvider configure INFO: connection properties: {user=root, password=root} 08-Dec-2003 10:55:31 net.sf.hibernate.transaction.TransactionManagerLookupFactory getTransactionManagerLookup INFO: No TransactionManagerLookup configured (in JTA environment, use of process level read-write cache is not recommended) 08-Dec-2003 10:55:31 net.sf.hibernate.cfg.SettingsFactory buildSettings INFO: Use scrollable result sets: true 08-Dec-2003 10:55:31 net.sf.hibernate.cfg.SettingsFactory buildSettings INFO: echoing all SQL to stdout 08-Dec-2003 10:55:31 net.sf.hibernate.cfg.SettingsFactory buildSettings INFO: Query language substitutions: {no='N', true=1, yes='Y', false=0} 08-Dec-2003 10:55:31 net.sf.hibernate.cfg.SettingsFactory buildSettings INFO: cache provider: net.sf.hibernate.cache.HashtableCacheProvider 08-Dec-2003 10:55:31 net.sf.hibernate.cfg.Configuration configureCaches INFO: instantiating and configuring caches 08-Dec-2003 10:55:31 net.sf.hibernate.impl.SessionFactoryImpl <init> INFO: building session factory 08-Dec-2003 10:55:32 net.sf.hibernate.impl.SessionFactoryObjectFactory addInstance INFO: no JNDI name configured Exception in thread "main" net.sf.hibernate.PropertyValueException: not-null property references a null or transient value: net.sf.hibernate.persister.EntityPersister.thing at net.sf.hibernate.impl.SessionImpl.checkNullability(SessionImpl.java:1208) at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:873) at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:817) at net.sf.hibernate.impl.SessionImpl.saveWithGeneratedIdentifier(SessionImpl.java:737) at net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:717) at net.sf.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:1319) at net.sf.hibernate.engine.Cascades$4.cascade(Cascades.java:114) at net.sf.hibernate.engine.Cascades.cascade(Cascades.java:436) at net.sf.hibernate.engine.Cascades.cascade(Cascades.java:503) at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:892) at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:817) at net.sf.hibernate.impl.SessionImpl.saveWithGeneratedIdentifier(SessionImpl.java:740) at net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:717) at test.IntVsUUIDOneToOneTest.main(IntVsUUIDOneToOneTest.java:27) Java Result: 1 for more examples, download the hibernate-examples package BUILD SUCCESSFUL Total time: 4 seconds Compilation finished at Mon Dec 8 10:55:32 --------------------------------------------------------------------- View the issue: http://opensource.atlassian.com/projects/hibernate/secure/ViewIssue.jspa?key=HB-531 Here is an overview of the issue: --------------------------------------------------------------------- Key: HB-531 Summary: One-To-One mappings with int/native ids don't work properly Type: Bug Status: Unassigned Priority: Critical Project: Hibernate2 Components: core Versions: 2.1 final 2.1 rc1 Assignee: Reporter: Hunter Kelly Created: Mon, 8 Dec 2003 4:49 AM Updated: Mon, 8 Dec 2003 4:56 AM Environment: RedHat Linux 9.0 MySQL 4.0.14-standard Latest Hibernate CVS tree Description: I have a one to one mapping in a class, Thing, that maps to IntThing and UUIDThing. IntThing and UUIDThing both define a many-to-one mapping back to Thing. Int thing uses "native" generator for id. UUID uses "uuid.hex" generator for id. I would have thought they'd behave the same, but they don't. I've built a truth table for each, where I changed the values of the "constrained" attribute on the one-to-one mapping and the "not-null" attribute on the many-to-one mapping. For UUID thing: Constrained = true | Constrained = false ------------------------------------------------------- Not-Null | | true | failed | sucess ------------------------------------------------------- Not-Null | false | success | success ------------------------------------------------------- For Int thing: Constrained = true | Constrained = false ------------------------------------------------------- Not-Null| | true | failed | failed ------------------------------------------------------- Not-Null| | false | success | failed ------------------------------------------------------- The above chart shows that regardless of what constrained is set to, you can't have a one-to-one mapping to an entity with an int id type that has a not-null constraint back to the parent. I'll attach the files now - to compile and run I just made a copy of the "eg" target in Hibernate's build.xml, uncommented the lines in hibernate.properties relevant to MySQL and changed the database name. --------------------------------------------------------------------- JIRA INFORMATION: This message is automatically generated by JIRA. If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa If you want more information on JIRA, or have a bug to report see: http://www.atlassian.com/software/jira |