3 entity class:
PoliceStation -> Archive -> Policeman
The 2 relations are both "one-to-many".
Junit console:
Code:
.[INFO] Environment - -Hibernate 2.0.3
[INFO] Environment - -loaded properties from resource hibernate.properties: {hibernate.connection.driver_class=org.gjt.mm.mysql.Driver, hibernate.cglib.use_reflection_optimizer=true, 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.query.imports=net.sf.hibernate.test, net.sf.hibernate.eg, hibernate.proxool.pool_alias=pool1, hibernate.connection.username=root, hibernate.connection.url=jdbc:mysql://localhost:3306/ps2003, hibernate.show_sql=true, hibernate.connection.provider_class=net.sf.hibernate.connection.DriverManagerConnectionProvider, hibernate.connection.password=, hibernate.statement_cache.size=25, hibernate.connection.pool_size=1}
[INFO] Environment - -using java.io streams to persist binary types
[INFO] Environment - -using CGLIB reflection optimizer
[INFO] Environment - -JVM proxy support: true
[INFO] Configuration - -Mapping resource: net/muziq/ps2003/entity/PoliceStation.hbm.xml
[INFO] Binder - -Mapping class: net.muziq.ps2003.entity.PoliceStation -> PoliceStation
[WARN] Binder - -Attribute "order-by" ignored in JDK1.3 or less
[INFO] Configuration - -Mapping resource: net/muziq/ps2003/entity/Archive.hbm.xml
[INFO] Binder - -Mapping class: net.muziq.ps2003.entity.Archive -> Archive
[INFO] Configuration - -Mapping resource: net/muziq/ps2003/entity/Policeman.hbm.xml
[INFO] Binder - -Mapping class: net.muziq.ps2003.entity.Policeman -> Policeman
[INFO] Configuration - -processing one-to-many association mappings
[INFO] Binder - -Mapping collection: net.muziq.ps2003.entity.PoliceStation.archives -> Archive
[INFO] Binder - -Mapping collection: net.muziq.ps2003.entity.Archive.policemen -> Policeman
[INFO] Configuration - -processing foreign key constraints
[INFO] SessionFactoryImpl - -building session factory
[INFO] Dialect - -Using dialect: net.sf.hibernate.dialect.MySQLDialect
[INFO] ConnectionProviderFactory - -Initializing connection provider: net.sf.hibernate.connection.DriverManagerConnectionProvider
[INFO] DriverManagerConnectionProvider - -Hibernate connection pool size: 1
[INFO] DriverManagerConnectionProvider - -using driver: org.gjt.mm.mysql.Driver at URL: jdbc:mysql://localhost:3306/ps2003
[INFO] DriverManagerConnectionProvider - -connection properties: {user=root, password=}
[INFO] PreparedStatementCache - -prepared statement cache size: 25
[INFO] SessionFactoryImpl - -Use outer join fetching: true
[INFO] SessionFactoryImpl - -Use scrollable result sets: true
[INFO] SessionFactoryImpl - -echoing all SQL to stdout
E
Time: 17.665
There was 1 error:
1) testAddPoliceStation(net.muziq.ps2003.entity.BussinessFacadeTest)java.lang.AbstractMethodError: net/sf/hibernate/persister/AbstractEntityPersister.insert
at net.sf.hibernate.loader.OuterJoinLoader.walkClassTree(OuterJoinLoader.java:172)
at net.sf.hibernate.loader.OuterJoinLoader.walkTree(OuterJoinLoader.java:74)
at net.sf.hibernate.loader.OneToManyLoader.<init>(OneToManyLoader.java:57)
at net.sf.hibernate.collection.CollectionPersister.createCollectionQuery(CollectionPersister.java:277)
at net.sf.hibernate.collection.CollectionPersister.<init>(CollectionPersister.java:268)
at net.sf.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:216)
at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:627)
at net.muziq.ps2003.BussinessFacade.getNewSession(BussinessFacade.java:82)
at net.muziq.ps2003.BussinessFacade.addPoliceStation(BussinessFacade.java:34)
at net.muziq.ps2003.entity.BussinessFacadeTest.testAddPoliceStation(BussinessFacadeTest.java:19)
at com.intellij.rt.execution.junit.TextTestRunner.main(TextTestRunner.java:12)
FAILURES!!!
Tests run: 1, Failures: 0, Errors: 1
PoliceStation.hbm.xml
Code:
<hibernate-mapping>
<class name="net.muziq.ps2003.entity.PoliceStation">
<id type="java.lang.String">
<generator class="hilo"/>
</id>
<set name="archives" lazy="true" inverse="true" cascade="all" order-by="year desc">
<key column="policeStation"/>
<one-to-many class="net.muziq.ps2003.entity.Archive"/>
</set>
</class>
</hibernate-mapping>
Archive.hbm.xml
Code:
<hibernate-mapping>
<class name="net.muziq.ps2003.entity.Archive">
<id type="java.lang.String">
<generator class="hilo"/>
</id>
<many-to-one name="policeStation" class="net.muziq.ps2003.entity.PoliceStation"/>
<set name="policemen" lazy="true" inverse="true" cascade="all">
<key column="archive"/>
<one-to-many class="net.muziq.ps2003.entity.Policeman"/>
</set>
<property name="year" type="java.lang.Integer"/>
<property name="name" type="java.lang.String"/>
</class>
</hibernate-mapping>
Policeman.hbm.xml
Code:
<hibernate-mapping>
<class name="net.muziq.ps2003.entity.Policeman">
<id type="java.lang.String">
<generator class="hilo"/>
</id>
<many-to-one name="archive" class="net.muziq.ps2003.entity.Archive"/>
</class>
</hibernate-mapping>
Need your help!