I am new to Hibernate , i am trying to do a code walk through with my sample customer table , and my Junit throws the stack below:
I am not sure where to look , i have checked on all avialable sources
on the web and have not seen any post that specifically addresses this error. i quess the error is too basic, i will appreciated any ideas.
if the problem is caused by enabling outer join fetching , how do i instrument my java code or what technique , do i use to correct it ?
thanks for your attention.
Hibernate version:
Mapping documents:
Code between sessionFactory.openSession() and session.close():
Full stack trace of any exception that occurs:
Buildfile: build.xml
build:
[javac] Compiling 1 source file to E:\hinetlogic\build
make-docs:
[javadoc] Generating Javadoc
[javadoc] Javadoc execution
[javadoc] Loading source files for package hinetlogic...
[javadoc] Loading source files for package hinetlogic.persistence...
[javadoc] Loading source files for package hinetlogic.test...
[javadoc] Loading source files for package hinetlogic.util...
[javadoc] Constructing Javadoc information...
[javadoc] Standard Doclet version 1.4.2_05
[javadoc] Building tree for all the packages and classes...
[javadoc] Building index for all the packages and classes...
[javadoc] Building index for all classes...
gen-classes:
[java] log4j:WARN No appenders could be found for logger (net.sf.hiberna
util.DTDEntityResolver).
[java] log4j:WARN Please initialize the log4j system properly.
make-props:
[propertyfile] Updating property file: E:\hinetlogic\config\hibernate.propert
init-db:
[schemaexport] log4j:WARN No appenders could be found for logger (net.sf.hibe
te.cfg.Environment).
[schemaexport] log4j:WARN Please initialize the log4j system properly.
run-tests:
[junit] Running hinetlogic.test.TestCustomerDAO
[junit] 23:53:29,931 INFO Environment:462 - Hibernate 2.1.2
[junit] 23:53:29,981 INFO Environment:496 - loaded properties from resou
hibernate.properties: {hibernate.connection.username=neuron, hibernate.conne
on.password=admin, hibernate.cglib.use_reflection_optimizer=true, hibernate.d
ect=net.sf.hibernate.dialect.DB2Dialect, hibernate.connection.url=jdbc:db2:sa
e, hibernate.connection.driver_class=COM.ibm.db2.jdbc.app.DB2Driver}
[junit] 23:53:29,991 INFO Environment:519 - using CGLIB reflection optim
r
[junit] 23:53:30,011 INFO Configuration:329 - Mapping resource: hinetlog
Customer.hbm.xml
[junit] 23:53:32,164 INFO Binder:229 - Mapping class: hinetlogic.Custome
> CUSTOMER
[junit] 23:53:32,534 INFO Configuration:595 - processing one-to-many ass
ation mappings
[junit] 23:53:32,534 INFO Binder:1154 - Mapping collection: hinetlogic.C
omer.customer -> CUSTOMER
[junit] 23:53:32,544 INFO Configuration:604 - processing one-to-one asso
tion property references
[junit] 23:53:32,544 INFO Configuration:629 - processing foreign key con
aints
[junit] 23:53:32,634 INFO Dialect:82 - Using dialect: net.sf.hibernate.d
ect.DB2Dialect
[junit] 23:53:32,664 INFO SettingsFactory:62 - Use outer join fetching:
e
[junit] 23:53:32,684 INFO DriverManagerConnectionProvider:41 - Using Hib
ate built-in connection pool (not for production use!)
[junit] 23:53:32,695 INFO DriverManagerConnectionProvider:42 - Hibernate
nnection pool size: 20
[junit] 23:53:32,815 INFO DriverManagerConnectionProvider:71 - using dri
: COM.ibm.db2.jdbc.app.DB2Driver at URL: jdbc:db2:sample
[junit] 23:53:32,815 INFO DriverManagerConnectionProvider:72 - connectio
roperties: {user=neuron, password=admin}
[junit] 23:53:32,875 INFO TransactionManagerLookupFactory:33 - No Transa
onManagerLookup configured (in JTA environment, use of process level read-wri
cache is not recommended)
[junit] 23:53:33,876 INFO Configuration:329 - Mapping resource: hinetlog
Customer.hbm.xml
[junit] 23:53:34,026 ERROR Configuration:252 - Could not compile the mapp
document
[junit] net.sf.hibernate.MappingException: duplicate import: Customer
[junit] at net.sf.hibernate.cfg.Mappings.addImport(Mappings.java:85)
[junit] at net.sf.hibernate.cfg.Binder.bindClass(Binder.java:126)
[junit] at net.sf.hibernate.cfg.Binder.bindRootClass(Binder.java:221)
[junit] at net.sf.hibernate.cfg.Binder.bindRoot(Binder.java:1229)
[junit] at net.sf.hibernate.cfg.Configuration.add(Configuration.java:
)
[junit] at net.sf.hibernate.cfg.Configuration.addInputStream(Configur
on.java:285)
[junit] at net.sf.hibernate.cfg.Configuration.addClass(Configuration.
a:333)
[junit] at hinetlogic.persistence.HibernateSession.loadClasses(Hibern
Session.java:67)
[junit] at hinetlogic.persistence.HibernateSession.currentSession(Hib
ateSession.java:20)
[junit] at hinetlogic.persistence.BaseDAO.retrieveObjs(BaseDAO.java:7
[junit] at hinetlogic.persistence.CustomerDAO.searchCustomer(Customer
.java:28)
[junit] at hinetlogic.test.TestCustomerDAO.testSelectCustomer(TestCus
erDAO.java:66)
[junit] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method
[junit] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAc
sorImpl.java:39)
[junit] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Delegating
hodAccessorImpl.java:25)
[junit] %%%% Error Creating SessionFactory %%%%
[junit] at java.lang.reflect.Method.invoke(Method.java:324)
[junit] at junit.framework.TestCase.runTest(TestCase.java:154)
[junit] at junit.framework.TestCase.runBare(TestCase.java:127)
[junit] at junit.framework.TestResult$1.protect(TestResult.java:106)
[junit] at junit.framework.TestResult.runProtected(TestResult.java:12
[junit] at junit.framework.TestResult.run(TestResult.java:109)
[junit] at junit.framework.TestCase.run(TestCase.java:118)
[junit] at junit.framework.TestSuite.runTest(TestSuite.java:208)
[junit] at junit.framework.TestSuite.run(TestSuite.java:203)
[junit] hinetlogic.persistence.DAOException: Error reading resource: hine
gic/Customer.hbm.xml wraps: [net.sf.hibernate.MappingException: Error reading
source: hinetlogic/Customer.hbm.xml]
[junit] at hinetlogic.persistence.HibernateSession.loadClasses(Hibern
Session.java:70)
[junit] at hinetlogic.persistence.HibernateSession.currentSession(Hib
ateSession.java:20)
[junit] at hinetlogic.persistence.BaseDAO.retrieveObjs(BaseDAO.java:7
[junit] at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunn
run(JUnitTestRunner.java:325)
[junit] at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunn
main(JUnitTestRunner.java:536)
[junit] at hinetlogic.persistence.CustomerDAO.searchCustomer(Customer
.java:28)
[junit] at hinetlogic.test.TestCustomerDAO.testSelectCustomer(TestCus
erDAO.java:66)
[junit] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method
[junit] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAc
sorImpl.java:39)
[junit] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Delegating
hodAccessorImpl.java:25)
[junit] at java.lang.reflect.Method.invoke(Method.java:324)
[junit] at junit.framework.TestCase.runTest(TestCase.java:154)
[junit] at junit.framework.TestCase.runBare(TestCase.java:127)
[junit] at junit.framework.TestResult$1.protect(TestResult.java:106)
[junit] at junit.framework.TestResult.runProtected(TestResult.java:12
[junit] at junit.framework.TestResult.run(TestResult.java:109)
[junit] at junit.framework.TestCase.run(TestCase.java:118)
[junit] at junit.framework.TestSuite.runTest(TestSuite.java:208)
[junit] at junit.framework.TestSuite.run(TestSuite.java:203)
[junit] at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunn
run(JUnitTestRunner.java:325)
[junit] at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunn
main(JUnitTestRunner.java:536)
[junit] net.sf.hibernate.MappingException: Error reading resource: hinetl
c/Customer.hbm.xml
[junit] at net.sf.hibernate.cfg.Configuration.addClass(Configuration.
a:336)
[junit] at hinetlogic.persistence.HibernateSession.loadClasses(Hibern
Session.java:67)
[junit] at hinetlogic.persistence.HibernateSession.currentSession(Hib
ateSession.java:20)
[junit] at hinetlogic.persistence.BaseDAO.retrieveObjs(BaseDAO.java:7
[junit] at hinetlogic.persistence.CustomerDAO.searchCustomer(Customer
.java:28)
[junit] at hinetlogic.test.TestCustomerDAO.testSelectCustomer(TestCus
erDAO.java:66)
[junit] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method
[junit] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAc
sorImpl.java:39)
[junit] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Delegating
hodAccessorImpl.java:25)
[junit] at java.lang.reflect.Method.invoke(Method.java:324)
[junit] at junit.framework.TestCase.runTest(TestCase.java:154)
[junit] at junit.framework.TestCase.runBare(TestCase.java:127)
[junit] at junit.framework.TestResult$1.protect(TestResult.java:106)
[junit] at junit.framework.TestResult.runProtected(TestResult.java:12
[junit] at junit.framework.TestResult.run(TestResult.java:109)
[junit] at junit.framework.TestCase.run(TestCase.java:118)
[junit] at junit.framework.TestSuite.runTest(TestSuite.java:208)
[junit] at junit.framework.TestSuite.run(TestSuite.java:203)
[junit] at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunn
run(JUnitTestRunner.java:325)
[junit] at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunn
main(JUnitTestRunner.java:536)
[junit] Caused by: net.sf.hibernate.MappingException: duplicate import: C
omer
[junit] at net.sf.hibernate.cfg.Mappings.addImport(Mappings.java:85)
[junit] at net.sf.hibernate.cfg.Binder.bindClass(Binder.java:126)
[junit] at net.sf.hibernate.cfg.Binder.bindRootClass(Binder.java:221)
[junit] at net.sf.hibernate.cfg.Binder.bindRoot(Binder.java:1229)
[junit] at net.sf.hibernate.cfg.Configuration.add(Configuration.java:
)
[junit] at net.sf.hibernate.cfg.Configuration.addInputStream(Configur
on.java:285)
[junit] at net.sf.hibernate.cfg.Configuration.addClass(Configuration.
a:333)
[junit] ... 19 more
[junit] net.sf.hibernate.MappingException: Error reading resource: hinetl
c/Customer.hbm.xml
[junit] at net.sf.hibernate.cfg.Configuration.addClass(Configuration.
a:336)
[junit] at hinetlogic.persistence.HibernateSession.loadClasses(Hibern
Session.java:67)
[junit] at hinetlogic.persistence.HibernateSession.currentSession(Hib
ateSession.java:20)
[junit] at hinetlogic.persistence.BaseDAO.retrieveObjs(BaseDAO.java:7
[junit] at hinetlogic.persistence.CustomerDAO.searchCustomer(Customer
.java:28)
[junit] at hinetlogic.test.TestCustomerDAO.testSelectCustomer(TestCus
erDAO.java:66)
[junit] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method
[junit] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAc
sorImpl.java:39)
[junit] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Delegating
hodAccessorImpl.java:25)
[junit] at java.lang.reflect.Method.invoke(Method.java:324)
[junit] at junit.framework.TestCase.runTest(TestCase.java:154)
[junit] at junit.framework.TestCase.runBare(TestCase.java:127)
[junit] at junit.framework.TestResult$1.protect(TestResult.java:106)
[junit] at junit.framework.TestResult.runProtected(TestResult.java:12
[junit] at junit.framework.TestResult.run(TestResult.java:109)
[junit] at junit.framework.TestCase.run(TestCase.java:118)
[junit] at junit.framework.TestSuite.runTest(TestSuite.java:208)
[junit] at junit.framework.TestSuite.run(TestSuite.java:203)
[junit] at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunn
run(JUnitTestRunner.java:325)
[junit] at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunn
main(JUnitTestRunner.java:536)
[junit] Caused by: net.sf.hibernate.MappingException: duplicate import: C
omer
[junit] at net.sf.hibernate.cfg.Mappings.addImport(Mappings.java:85)
[junit] at net.sf.hibernate.cfg.Binder.bindClass(Binder.java:126)
[junit] at net.sf.hibernate.cfg.Binder.bindRootClass(Binder.java:221)
[junit] at net.sf.hibernate.cfg.Binder.bindRoot(Binder.java:1229)
[junit] %%%% wrapped exception: %%%% wrapped exception: Tests run: 2, Fai
es: 1, Errors: 1, Time elapsed: 4.557 sec
[junit] at net.sf.hibernate.cfg.Configuration.add(Configuration.java:
)
[junit] at net.sf.hibernate.cfg.Configuration.addInputStream(Configur
on.java:285)
[junit] at net.sf.hibernate.cfg.Configuration.addClass(Configuration.
a:333)
[junit] ... 19 more
[junit] Test hinetlogic.test.TestCustomerDAO FAILED
all:
BUILD SUCCESSFUL
Total time: 32 seconds
Name and version of the database you are using:
I am using ibm database(DB2)
The generated SQL (show_sql=true):
Debug level Hibernate log excerpt:
|