Hi
I am trying to develop a persistent framework with Hibernate, and using Hibernate 2.1, and MySql as my data store. The example provided in the Hibernate source distribution works (I mean the one with User, Bid, AuctionItem etc). But when I am trying to test my initial framework, the following exception is thrown:
Code:
F:\Work\working\mygrid\MIR>ant -f mir-in.xml test
Buildfile: mir-in.xml
test:
[echo] remember to place your JDBC driver in the lib directory
[java] Creating configuration...
[java] 09:06:23,506 INFO Environment:462 - Hibernate 2.1.2
[java] 09:06:23,537 INFO Environment:496 - loaded properties from resource hibernate.properties: {hibernate.connection.driver_class=org.gjt.mm.mysql.Driver, hibernate.cglib.use_reflection_optimizer=true, hibernate.cache.provider_class=net.sf.hibernate.cache.HashtableCacheProvider, hibernate.cache.use_query_cache=true, 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=arijitm, hibernate.connection.url=jdbc:mysql://localhost:3306/mir, hibernate.connection.password=password, hibernate.connection.pool_size=1}
[java] 09:06:23,553 INFO Environment:518 - using java.io streams to persist binary types
[java] 09:06:23,553 INFO Environment:519 - using CGLIB reflection optimizer
[java] 09:06:23,569 INFO Configuration:329 - Mapping resource: uk/org/mygrid/mir/infomodel/PeopleAndOrganizations/Person.hbm.xml
[java] 09:06:24,147 DEBUG DTDEntityResolver:20 - trying to locate http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd in classpath under net/sf/hibernate/
[java] 09:06:24,147 DEBUG DTDEntityResolver:29 - found http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd in classpath
[java] 09:06:24,397 INFO Binder:229 - Mapping class: uk.org.mygrid.mir.infomodel.PeopleAndOrganizations.Person -> person
[java] 09:06:24,506 DEBUG Binder:462 - Mapped property: id -> PID, type: long
[java] 09:06:24,553 DEBUG Binder:462 - Mapped property: x509DN -> X509, type: string
[java] 09:06:24,553 DEBUG Binder:462 - Mapped property: firstName -> FNAME, type: string
[java] 09:06:24,553 DEBUG Binder:462 - Mapped property: lastName -> LNAME, type: string
[java] 09:06:24,553 DEBUG Binder:462 - Mapped property: email -> EMAIL, type: string
[java] 09:06:24,584 DEBUG Binder:462 - Mapped property: theAddress, type: java.util.Collection
[java] 09:06:24,584 DEBUG Binder:462 - Mapped property: theAffiliation, type: java.util.Collection
[java] 09:06:24,584 INFO Configuration:329 - Mapping resource: uk/org/mygrid/mir/infomodel/PeopleAndOrganizations/Address.hbm.xml
[java] 09:06:24,616 DEBUG DTDEntityResolver:20 - trying to locate http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd in classpath under net/sf/hibernate/
[java] 09:06:24,616 DEBUG DTDEntityResolver:29 - found http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd in classpath
[java] 09:06:24,647 INFO Binder:229 - Mapping class: uk.org.mygrid.mir.infomodel.PeopleAndOrganizations.Address -> address
[java] 09:06:24,647 DEBUG Binder:462 - Mapped property: id -> ADDRID, type: long
[java] 09:06:24,662 DEBUG Binder:462 - Mapped property: extadd -> EXTADD, type: string
[java] 09:06:24,662 DEBUG Binder:462 - Mapped property: street -> STREET, type: string
[java] 09:06:24,662 DEBUG Binder:462 - Mapped property: locality -> LOCALITY, type: string
[java] 09:06:24,662 DEBUG Binder:462 - Mapped property: city -> CITY, type: string
[java] 09:06:24,662 DEBUG Binder:462 - Mapped property: pcode -> PCODE, type: string
[java] 09:06:24,662 DEBUG Binder:462 - Mapped property: country -> COUNTRY, type: string
[java] 09:06:24,678 DEBUG Binder:462 - Mapped property: addressee -> PID, type: uk.org.mygrid.mir.infomodel.PeopleAndOrganizations.Person
[java] 09:06:24,678 INFO Configuration:329 - Mapping resource: uk/org/mygrid/mir/infomodel/PeopleAndOrganizations/OrganizationalStructure.hbm.xml
[java] 09:06:24,694 DEBUG DTDEntityResolver:20 - trying to locate http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd in classpath under net/sf/hibernate/
[java] 09:06:24,694 DEBUG DTDEntityResolver:29 - found http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd in classpath
[java] 09:06:24,756 INFO Binder:229 - Mapping class: uk.org.mygrid.mir.infomodel.PeopleAndOrganizations.OrganizationalStructure -> organizationalstructure
[java] 09:06:24,756 DEBUG Binder:462 - Mapped property: id -> ORGID, type: long
[java] 09:06:24,756 DEBUG Binder:462 - Mapped property: orgName -> NAME, type: string
[java] 09:06:24,756 DEBUG Binder:462 - Mapped property: LSID -> LSID, type: string
[java] 09:06:24,756 DEBUG Binder:462 - Mapped property: thAffiliation, type: java.util.Collection
[java] 09:06:24,756 INFO Configuration:329 - Mapping resource: uk/org/mygrid/mir/infomodel/PeopleAndOrganizations/Affiliation.hbm.xml
[java] 09:06:24,772 DEBUG DTDEntityResolver:20 - trying to locate http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd in classpath under net/sf/hibernate/
[java] 09:06:24,787 DEBUG DTDEntityResolver:29 - found http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd in classpath
[java] 09:06:24,819 INFO Binder:229 - Mapping class: uk.org.mygrid.mir.infomodel.PeopleAndOrganizations.Affiliation -> affiliation
[java] 09:06:24,819 DEBUG Binder:462 - Mapped property: id -> AFFILIATIONID, type: long
[java] 09:06:24,834 DEBUG Binder:462 - Mapped property: theAffiliationEpisode, type: java.util.Collection
[java] 09:06:24,834 DEBUG Binder:462 - Mapped property: theOrganizationalStructure -> ORGID, type: uk.org.mygrid.mir.infomodel.PeopleAndOrganizations.OrganizationalStructure
[java] 09:06:24,834 INFO Configuration:329 - Mapping resource: uk/org/mygrid/mir/infomodel/PeopleAndOrganizations/AffiliationStatus.hbm.xml
[java] 09:06:24,866 DEBUG DTDEntityResolver:20 - trying to locate http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd in classpath under net/sf/hibernate/
[java] 09:06:24,866 DEBUG DTDEntityResolver:29 - found http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd in classpath
[java] 09:06:24,912 INFO Binder:229 - Mapping class: uk.org.mygrid.mir.infomodel.PeopleAndOrganizations.AffiliationStatus -> affiliationstatus
[java] 09:06:24,912 DEBUG Binder:462 - Mapped property: id -> AFFSTATUSID, type: long
[java] 09:06:24,912 DEBUG Binder:462 - Mapped property: statusName -> NAME, type: string
[java] 09:06:24,912 DEBUG Binder:462 - Mapped property: description -> DESCR, type: string
[java] 09:06:24,912 DEBUG Binder:462 - Mapped property: theAffiliationEpisode, type: java.util.Collection
[java] 09:06:24,912 INFO Configuration:329 - Mapping resource: uk/org/mygrid/mir/infomodel/PeopleAndOrganizations/AffiliationEpisode.hbm.xml
[java] 09:06:24,944 DEBUG DTDEntityResolver:20 - trying to locate http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd in classpath under net/sf/hibernate/
[java] 09:06:24,944 DEBUG DTDEntityResolver:29 - found http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd in classpath
[java] 09:06:24,991 INFO Binder:229 - Mapping class: uk.org.mygrid.mir.infomodel.PeopleAndOrganizations.AffiliationEpisode -> affiliationepisode
[java] 09:06:25,006 DEBUG Binder:462 - Mapped property: id -> AFFEPISODEID, type: long
[java] 09:06:25,006 DEBUG Binder:462 - Mapped property: startDate -> START_DATE, type: date
[java] 09:06:25,006 DEBUG Binder:462 - Mapped property: endDate -> END_DATE, type: date
[java] 09:06:25,006 DEBUG Binder:462 - Mapped property: theAffiliationStatus -> AFFSTATUSID, type: uk.org.mygrid.mir.infomodel.PeopleAndOrganizations.AffiliationStatus
[java] 09:06:25,006 DEBUG Binder:462 - Mapped property: theAffiliation -> AFFILIATIONID, type: uk.org.mygrid.mir.infomodel.PeopleAndOrganizations.Affiliation
[java] 09:06:25,006 INFO Configuration:595 - processing one-to-many association mappings
[java] 09:06:25,006 DEBUG Binder:1326 - Second pass for collection: uk.org.mygrid.mir.infomodel.PeopleAndOrganizations.Person.theAddress
[java] 09:06:25,006 INFO Binder:1154 - Mapping collection: uk.org.mygrid.mir.infomodel.PeopleAndOrganizations.Person.theAddress -> address
[java] 09:06:25,006 DEBUG Binder:1341 - Mapped collection key: ADDRID, one-to-many: uk.org.mygrid.mir.infomodel.PeopleAndOrganizations.Address
[java] 09:06:25,006 DEBUG Binder:1326 - Second pass for collection: uk.org.mygrid.mir.infomodel.PeopleAndOrganizations.Person.theAffiliation
[java] 09:06:25,037 INFO Binder:1154 - Mapping collection: uk.org.mygrid.mir.infomodel.PeopleAndOrganizations.Person.theAffiliation -> affiliation
[java] 09:06:25,037 DEBUG Binder:1341 - Mapped collection key: AFFILIATIONID, one-to-many: uk.org.mygrid.mir.infomodel.PeopleAndOrganizations.Affiliation
[java] 09:06:25,037 DEBUG Binder:1326 - Second pass for collection: uk.org.mygrid.mir.infomodel.PeopleAndOrganizations.OrganizationalStructure.theAffiliation
[java] 09:06:25,037 INFO Binder:1154 - Mapping collection: uk.org.mygrid.mir.infomodel.PeopleAndOrganizations.OrganizationalStructure.theAffiliation -> affiliation
[java] 09:06:25,053 DEBUG Binder:1341 - Mapped collection key: AFFILIATIONID, one-to-many: uk.org.mygrid.mir.infomodel.PeopleAndOrganizations.Affiliation
[java] 09:06:25,053 DEBUG Binder:1326 - Second pass for collection: uk.org.mygrid.mir.infomodel.PeopleAndOrganizations.Affiliation.theAffiliationEpisode
[java] 09:06:25,069 INFO Binder:1154 - Mapping collection: uk.org.mygrid.mir.infomodel.PeopleAndOrganizations.Affiliation.theAffiliationEpisode -> affiliationepisode
[java] 09:06:25,069 DEBUG Binder:1341 - Mapped collection key: AFFEPISODEID, one-to-many: uk.org.mygrid.mir.infomodel.PeopleAndOrganizations.AffiliationEpisode
[java] 09:06:25,084 DEBUG Binder:1326 - Second pass for collection: uk.org.mygrid.mir.infomodel.PeopleAndOrganizations.AffiliationStatus.theAffiliationEpisode
[java] 09:06:25,084 INFO Binder:1154 - Mapping collection: uk.org.mygrid.mir.infomodel.PeopleAndOrganizations.AffiliationStatus.theAffiliationEpisode -> affiliationepisode
[java] 09:06:25,100 DEBUG Binder:1341 - Mapped collection key: AFFEPISODEID, one-to-many: uk.org.mygrid.mir.infomodel.PeopleAndOrganizations.AffiliationEpisode
[java] 09:06:25,100 INFO Configuration:604 - processing one-to-one association property references
[java] 09:06:25,116 INFO Configuration:629 - processing foreign key constraints
[java] 09:06:25,116 DEBUG Configuration:639 - resolving reference to class: uk.org.mygrid.mir.infomodel.PeopleAndOrganizations.Person
[java] 09:06:25,116 DEBUG Configuration:639 - resolving reference to class: uk.org.mygrid.mir.infomodel.PeopleAndOrganizations.OrganizationalStructure
[java] 09:06:25,116 DEBUG Configuration:639 - resolving reference to class: uk.org.mygrid.mir.infomodel.PeopleAndOrganizations.Affiliation
[java] 09:06:25,116 DEBUG Configuration:639 - resolving reference to class: uk.org.mygrid.mir.infomodel.PeopleAndOrganizations.AffiliationStatus
[java] 09:06:25,178 INFO Dialect:82 - Using dialect: net.sf.hibernate.dialect.MySQLDialect
[java] 09:06:25,178 INFO SettingsFactory:58 - Maximim outer join fetch depth: 1
[java] 09:06:25,178 INFO SettingsFactory:62 - Use outer join fetching: true
[java] 09:06:25,194 INFO DriverManagerConnectionProvider:41 - Using Hibernate built-in connection pool (not for production use!)
[java] 09:06:25,194 INFO DriverManagerConnectionProvider:42 - Hibernate connection pool size: 1
[java] 09:06:25,209 INFO DriverManagerConnectionProvider:71 - using driver: org.gjt.mm.mysql.Driver at URL: jdbc:mysql://localhost:3306/mir
[java] 09:06:25,209 INFO DriverManagerConnectionProvider:72 - connection properties: {user=arijitm, password=password}
[java] 09:06:25,225 INFO TransactionManagerLookupFactory:33 - No TransactionManagerLookup configured (in JTA environment, use of process level r
ead-write cache is not recommended)
[java] 09:06:25,225 DEBUG DriverManagerConnectionProvider:78 - total checked-out connections: 0
[java] 09:06:25,225 DEBUG DriverManagerConnectionProvider:94 - opening new JDBC connection
[java] 09:06:25,475 DEBUG DriverManagerConnectionProvider:100 - created connection to: jdbc:mysql://localhost:3306/mir, Isolation Level: 4
[java] 09:06:25,475 DEBUG DriverManagerConnectionProvider:114 - returning connection to pool, pool size: 1
[java] 09:06:25,475 INFO SettingsFactory:102 - Use scrollable result sets: true
[java] 09:06:25,491 INFO SettingsFactory:105 - Use JDBC3 getGeneratedKeys(): true
[java] 09:06:25,491 INFO SettingsFactory:108 - Optimize cache for minimal puts: false
[java] 09:06:25,491 INFO SettingsFactory:117 - Query language substitutions: {no='N', true=1, yes='Y', false=0}
[java] 09:06:25,491 INFO SettingsFactory:128 - cache provider: net.sf.hibernate.cache.HashtableCacheProvider
[java] 09:06:25,491 INFO Configuration:1080 - instantiating and configuring caches
[java] 09:06:25,647 INFO SessionFactoryImpl:119 - building session factory
[java] java.lang.RuntimeException: couldn't get connection
[java] at uk.org.mygrid.mir.test.HibernateTest.main(HibernateTest.java:165)
[java] Exception in thread "main"
BUILD FAILED
file:F:/Work/working/mygrid/MIR/mir-in.xml:69: Java returned: 1
Total time: 4 seconds
When I tried to use the hbm2ddl on the same mapping files, using an Ant target, it worked, and my tables were created. But trying to test my framework through a java test application fails. It doesn't even create the session factory, because the code fails at the buildSessionFactory call in the following segment:
Code:
System.out.println("Creating configuration...");
Configuration cfg = new Configuration()
.addClass(uk.org.mygrid.mir.infomodel.PeopleAndOrganizations.Person.class)
.addClass(uk.org.mygrid.mir.infomodel.PeopleAndOrganizations.Address.class)
.addClass(uk.org.mygrid.mir.infomodel.PeopleAndOrganizations.OrganizationalStructure.class)
.addClass(uk.org.mygrid.mir.infomodel.PeopleAndOrganizations.Affiliation.class)
.addClass(uk.org.mygrid.mir.infomodel.PeopleAndOrganizations.AffiliationStatus.class)
.addClass(uk.org.mygrid.mir.infomodel.PeopleAndOrganizations.AffiliationEpisode.class)
.setProperty(Environment.HBM2DDL_AUTO, "create");
test.factory = cfg.buildSessionFactory();
test.createTestData();
May be my mapping files and the java classes are wrong - but does it affect the buildSessionFactory call? The how come the hbm2ddl generates the schema and creates the table in my DB?
Waiting for your answer.....
Arijit