-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: one-to-one
PostPosted: Mon Dec 18, 2006 4:51 pm 
Newbie

Joined: Sat Dec 16, 2006 6:19 pm
Posts: 3
Hi,

Who can help me with this one-to-one relation. I can not get it to work. An employee is composition of a Person(POJO) and a mailaddress(String). When I create a new employee and want save it to the DB thru hibernate, I can not get it to work.

Thanks for reading my problem

Pieter

mySQL DB script
Code:
DROP TABLE IF EXISTS `person`;
CREATE TABLE `person` (
  `uid` int(10) unsigned NOT NULL default '0',
  `firstname` varchar(50) NOT NULL default '',
  PRIMARY KEY  (`uid`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

DROP TABLE IF EXISTS `employee`;
CREATE TABLE `employee` (
  `personid` int(10) unsigned NOT NULL default '0',
  `mailAddress` varchar(45) NOT NULL default '',
  PRIMARY KEY  (`personid`),
  CONSTRAINT `FK_employee_1` FOREIGN KEY (`personid`) REFERENCES `person` (`uid`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=latin1;


mapping files:
Employee.hbm.xml
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="cvo.test">
   <class name="Employee" table="employee" lazy="false">
      <id name="person" column="personid" type="cvo.test.Person">
         <generator class="foreign">
            <param name="property">person</param>
            <param name="table">person</param>
            <param name="column">uid</param>
         </generator>
      </id>
      <property name="mailAddress" column="mailAddress"/>
      <one-to-one name="person" class="Person" cascade="all">
      </one-to-one>
   </class>
</hibernate-mapping>


Person.hbm.xml
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="cvo.test">
   <class name="Person" table="person" lazy="false">
      <id name="uid" column="uid" type="java.lang.Integer">
         <generator class="assigned"/>
      </id>
      <property name="firstname" column="firstname"/>
   </class>
</hibernate-mapping>


hibernate.cfg.xml
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
   <session-factory>
      <property name="connection.driver_class">
    com.mysql.jdbc.Driver
  </property>
      <property name="connection.url">
     jdbc:mysql://localhost/hibtest
  </property>
      <property name="dialect">
     org.hibernate.dialect.MySQLDialect
  </property>
      <property name="connection.username">root</property>
      <property name="connection.password">root</property>
      <property name="show_sql">true</property>
      <mapping resource="Person.hbm.xml"/>
      <mapping resource="Employee.hbm.xml"/>
   </session-factory>
</hibernate-configuration>


log4j.properties
Code:
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}: - %m%n
### set log levels - for more verbose logging
### change 'info' to 'debug‘
log4j.rootLogger=debug, stdout
log4j.logger.net.sf.hibernate=warn


HibernateUtil.java
Code:
package cvo.test;

import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;

public class HibernateUtil {
   private static String CFG_FILE = "/hibernate.cfg.xml";

   private static final ThreadLocal tl = new ThreadLocal();

   private static final Configuration cfg = new Configuration();

   private static SessionFactory factory;

   private HibernateUtil() {
   }

   public static Session currentSession() throws HibernateException {

      Session session = (Session) tl.get();
      if (session == null) {
         if (factory == null) {
            try {
               cfg.configure(CFG_FILE);
               factory = cfg.buildSessionFactory();
            } catch (Exception e) {
               System.err.println("Error Creating SessionFactory");
               e.printStackTrace();
            }
         }
         session = factory.openSession();
         tl.set(session);
      }
      return session;
   }

   public static void closeSession() throws HibernateException {

      Session session = (Session) tl.get();
      tl.set(null);

      if (session != null) {
         session.close();
      }

   }

}


Employee.java
Code:
package cvo.test;

import java.io.Serializable;

public class Employee implements Serializable {

   
   private static final long serialVersionUID = 1L;

   private Person person;

   private String mailAddress;

   public Employee() {
      super();
   }

   public Employee(Person person, String mailAddress) {
      super();
      this.person = person;
      this.mailAddress = mailAddress;
   }
   
   public Employee(Integer id, String firstname, String mailAddress) {
      super();
      this.person = new Person(id, firstname);
      this.mailAddress = mailAddress;
   }

   public String getMailAddress() {
      return mailAddress;
   }

   public void setMailAddress(String mailAddress) {
      this.mailAddress = mailAddress;
   }

   public Person getPerson() {
      return person;
   }

   public void setPerson(Person person) {
      this.person = person;
   }

   public String toString() {
      StringBuffer buffer = new StringBuffer();
      buffer.append("[Employee:");
      buffer.append(" person: ");
      buffer.append(person);
      buffer.append(" mailAddress: ");
      buffer.append(mailAddress);
      buffer.append("]");
      return buffer.toString();
   }

   public boolean equals(Object o) {
      if (this == o) {
         return true;
      }
      if (o == null) {
         return false;
      }
      if (o.getClass() != getClass()) {
         return false;
      }
      Employee castedObj = (Employee) o;
      return ((this.person == null ? castedObj.person == null : this.person
            .equals(castedObj.person)) && (this.mailAddress == null ? castedObj.mailAddress == null
            : this.mailAddress.equals(castedObj.mailAddress)));
   }

}


Person.java
Code:
package cvo.test;

import java.io.Serializable;

public class Person implements Serializable {


   private static final long serialVersionUID = 1L;

   private Integer uid;

   private String firstname;

   public Person() {
   }

   public Person(Integer uid, String firstname) {
      super();
      this.uid = uid;
      this.firstname = firstname;
   }

   public String getFirstname() {
      return firstname;
   }

   public void setFirstname(String firstname) {
      this.firstname = firstname;
   }

   public Integer getUid() {
      return uid;
   }

   public void setUid(Integer uid) {
      this.uid = uid;
   }

   public String toString() {
      StringBuffer buffer = new StringBuffer();
      buffer.append("[Person:");
      buffer.append(" uid: ");
      buffer.append(uid);
      buffer.append(" firstname: ");
      buffer.append(firstname);
      buffer.append("]");
      return buffer.toString();
   }

   public boolean equals(Object o) {
      if (this == o) {
         return true;
      }
      if (o == null) {
         return false;
      }
      if (o.getClass() != getClass()) {
         return false;
      }
      Person castedObj = (Person) o;
      return ((this.uid == null ? castedObj.uid == null : this.uid
            .equals(castedObj.uid)) && (this.firstname == null ? castedObj.firstname == null
            : this.firstname.equals(castedObj.firstname)));
   }

}


Main.java
Code:
package cvo.test;

import org.hibernate.Session;
import org.hibernate.Transaction;


public class Main {

   /**
    * @param args
    */
   public static void main(String[] args) {
      
      Session session = (Session) HibernateUtil.currentSession();
      
      Person person = new Person(10, "pieter");
      Employee employee = new Employee(person, "pieter.raemdonck@pfizer.com");
      Transaction trans = session.beginTransaction();
      session.saveOrUpdate(employee);
      trans.commit();
      trans = null;
      


   }

}


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 19, 2006 5:13 am 
Expert
Expert

Joined: Tue Dec 28, 2004 7:02 am
Posts: 573
Location: Toulouse, France
What is your error...

_________________
Baptiste
PS : please don't forget to give credits below if you found this answer useful :)


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 19, 2006 1:48 pm 
Newbie

Joined: Sat Dec 16, 2006 6:19 pm
Posts: 3
here is the console output
Code:
18:44:21,769  INFO Environment: - Hibernate 3.2.1
18:44:21,779  INFO Environment: - hibernate.properties not found
18:44:21,779  INFO Environment: - Bytecode provider name : cglib
18:44:21,799  INFO Environment: - using JDK 1.4 java.sql.Timestamp handling
18:44:21,919  INFO Configuration: - configuring from resource: /hibernate.cfg.xml
18:44:21,919  INFO Configuration: - Configuration resource: /hibernate.cfg.xml
18:44:22,059 DEBUG DTDEntityResolver: - trying to resolve system-id [http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd]
18:44:22,600 DEBUG DTDEntityResolver: - recognized hibernate namespace; attempting to resolve on classpath under org/hibernate/
18:44:22,600 DEBUG DTDEntityResolver: - located [http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd] in classpath
18:44:22,640 DEBUG Configuration: - connection.driver_class=com.mysql.jdbc.Driver
18:44:22,640 DEBUG Configuration: - connection.url=jdbc:mysql://localhost/hibtest
18:44:22,640 DEBUG Configuration: - dialect=org.hibernate.dialect.MySQLDialect
18:44:22,640 DEBUG Configuration: - connection.username=root
18:44:22,650 DEBUG Configuration: - connection.password=root
18:44:22,650 DEBUG Configuration: - show_sql=true
18:44:22,650 DEBUG Configuration: - null<-org.dom4j.tree.DefaultAttribute@15663a2 [Attribute: name resource value "Person.hbm.xml"]
18:44:22,650  INFO Configuration: - Reading mappings from resource : Person.hbm.xml
18:44:22,650 DEBUG DTDEntityResolver: - trying to resolve system-id [http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd]
18:44:22,650 DEBUG DTDEntityResolver: - recognized hibernate namespace; attempting to resolve on classpath under org/hibernate/
18:44:22,660 DEBUG DTDEntityResolver: - located [http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd] in classpath
18:44:22,810  INFO HbmBinder: - Mapping class: cvo.test.Person -> person
18:44:22,820 DEBUG HbmBinder: - Mapped property: uid -> uid
18:44:22,840 DEBUG HbmBinder: - Mapped property: firstname -> firstname
18:44:22,840 DEBUG Configuration: - null<-org.dom4j.tree.DefaultAttribute@176e552 [Attribute: name resource value "Employee.hbm.xml"]
18:44:22,840  INFO Configuration: - Reading mappings from resource : Employee.hbm.xml
18:44:22,840 DEBUG DTDEntityResolver: - trying to resolve system-id [http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd]
18:44:22,840 DEBUG DTDEntityResolver: - recognized hibernate namespace; attempting to resolve on classpath under org/hibernate/
18:44:22,840 DEBUG DTDEntityResolver: - located [http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd] in classpath
18:44:22,870  INFO HbmBinder: - Mapping class: cvo.test.Employee -> employee
18:44:22,870 DEBUG HbmBinder: - Mapped property: person -> personid
18:44:22,880 DEBUG HbmBinder: - Mapped property: mailAddress -> mailAddress
18:44:22,890 DEBUG HbmBinder: - Mapped property: person
18:44:22,890  INFO Configuration: - Configured SessionFactory: null
18:44:22,890 DEBUG Configuration: - properties: {hibernate.connection.password=root, java.runtime.name=Java(TM) 2 Runtime Environment, Standard Edition, sun.boot.library.path=C:\app\jdk1.5.0_02\jre\bin, java.vm.version=1.5.0_02-b09, hibernate.connection.username=root, java.vm.vendor=Sun Microsystems Inc., java.vendor.url=http://java.sun.com/, path.separator=;, java.vm.name=Java HotSpot(TM) Client VM, file.encoding.pkg=sun.io, user.country=US, sun.os.patch.level=Service Pack 2, java.vm.specification.name=Java Virtual Machine Specification, user.dir=C:\data\java5\examen\examenOneToOneTest, java.runtime.version=1.5.0_02-b09, java.awt.graphicsenv=sun.awt.Win32GraphicsEnvironment, java.endorsed.dirs=C:\app\jdk1.5.0_02\jre\lib\endorsed, os.arch=x86, java.io.tmpdir=C:\DOCUME~1\RaemdoP\LOCALS~1\Temp\, line.separator=
, java.vm.specification.vendor=Sun Microsystems Inc., user.variant=, os.name=Windows XP, sun.jnu.encoding=Cp1252, java.library.path=C:\app\jdk1.5.0_02\bin;.;C:\WINNT\system32;C:\WINNT;C:\Program Files\ThinkPad\Utilities;C:\WINNT\system32;C:\WINNT;C:\WINNT\System32\Wbem;C:\Program Files\Support Tools\;C:\Program Files\Intel\Wireless\Bin\;C:\Program Files\ATI Technologies\ATI Control Panel;C:\Program Files\Intel\Wireless\Bin\;C:\Program Files\Intel\Wireless\Bin\;C:\Program Files\Common Files\Ulead Systems\MPEG;C:\Program Files\Microsoft SQL Server\80\Tools\Binn\;C:\Program Files\Microsoft SQL Server\90\Tools\binn\;C:\Program Files\Microsoft SQL Server\90\DTS\Binn\;C:\Program Files\Microsoft SQL Server\90\Tools\Binn\VSShell\Common7\IDE\;C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\PrivateAssemblies\, java.specification.name=Java Platform API Specification, java.class.version=49.0, sun.management.compiler=HotSpot Client Compiler, os.version=5.1, connection.password=root, user.home=C:\Documents and Settings\RaemdoP, user.timezone=Europe/Paris, connection.username=root, java.awt.printerjob=sun.awt.windows.WPrinterJob, file.encoding=Cp1252, java.specification.version=1.5, hibernate.connection.driver_class=com.mysql.jdbc.Driver, show_sql=true, user.name=RaemdoP, java.class.path=C:\data\java5\examen\examenOneToOneTest\bin;C:\data\java5\examen\examenOneToOneTest\lib\antlr-2.7.6.jar;C:\data\java5\examen\examenOneToOneTest\lib\asm.jar;C:\data\java5\examen\examenOneToOneTest\lib\asm-attrs.jar;C:\data\java5\examen\examenOneToOneTest\lib\cglib-2.1.3.jar;C:\data\java5\examen\examenOneToOneTest\lib\commons-collections-2.1.1.jar;C:\data\java5\examen\examenOneToOneTest\lib\commons-logging-1.0.4.jar;C:\data\java5\examen\examenOneToOneTest\lib\concurrent-1.3.2.jar;C:\data\java5\examen\examenOneToOneTest\lib\dom4j-1.6.1.jar;C:\data\java5\examen\examenOneToOneTest\lib\ehcache-1.2.3.jar;C:\data\java5\examen\examenOneToOneTest\lib\hibernate3.jar;C:\data\java5\examen\examenOneToOneTest\lib\jta.jar;C:\data\java5\examen\examenOneToOneTest\lib\log4j-1.2.11.jar;C:\data\java5\examen\examenOneToOneTest\lib\mysql-connector-java-3.1.10-bin.jar, hibernate.bytecode.use_reflection_optimizer=false, hibernate.show_sql=true, java.vm.specification.version=1.0, java.home=C:\app\jdk1.5.0_02\jre, sun.arch.data.model=32, hibernate.dialect=org.hibernate.dialect.MySQLDialect, hibernate.connection.url=jdbc:mysql://localhost/hibtest, user.language=en, java.specification.vendor=Sun Microsystems Inc., awt.toolkit=sun.awt.windows.WToolkit, java.vm.info=mixed mode, java.version=1.5.0_02, java.ext.dirs=C:\app\jdk1.5.0_02\jre\lib\ext, sun.boot.class.path=C:\app\jdk1.5.0_02\jre\lib\rt.jar;C:\app\jdk1.5.0_02\jre\lib\i18n.jar;C:\app\jdk1.5.0_02\jre\lib\sunrsasign.jar;C:\app\jdk1.5.0_02\jre\lib\jsse.jar;C:\app\jdk1.5.0_02\jre\lib\jce.jar;C:\app\jdk1.5.0_02\jre\lib\charsets.jar;C:\app\jdk1.5.0_02\jre\classes, java.vendor=Sun Microsystems Inc., connection.driver_class=com.mysql.jdbc.Driver, file.separator=\, java.vendor.url.bug=http://java.sun.com/cgi-bin/bugreport.cgi, sun.io.unicode.encoding=UnicodeLittle, sun.cpu.endian=little, sun.desktop=windows, connection.url=jdbc:mysql://localhost/hibtest, dialect=org.hibernate.dialect.MySQLDialect, sun.cpu.isalist=pentium_pro+mmx pentium_pro pentium+mmx pentium i486 i386 i86}
18:44:22,890 DEBUG Configuration: - Preparing to build session factory with filters : {}
18:44:22,890 DEBUG Configuration: - processing extends queue
18:44:22,890 DEBUG Configuration: - processing collection mappings
18:44:22,890 DEBUG Configuration: - processing native query and ResultSetMapping mappings
18:44:22,890 DEBUG Configuration: - processing association property references
18:44:22,890 DEBUG Configuration: - processing foreign key constraints
18:44:23,020  INFO DriverManagerConnectionProvider: - Using Hibernate built-in connection pool (not for production use!)
18:44:23,020  INFO DriverManagerConnectionProvider: - Hibernate connection pool size: 20
18:44:23,020  INFO DriverManagerConnectionProvider: - autocommit mode: false
18:44:23,061  INFO DriverManagerConnectionProvider: - using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql://localhost/hibtest
18:44:23,061  INFO DriverManagerConnectionProvider: - connection properties: {user=root, password=root}
18:44:23,061 DEBUG DriverManagerConnectionProvider: - total checked-out connections: 0
18:44:23,061 DEBUG DriverManagerConnectionProvider: - opening new JDBC connection
18:44:23,561 DEBUG DriverManagerConnectionProvider: - created connection to: jdbc:mysql://localhost/hibtest, Isolation Level: 4
18:44:23,561  INFO SettingsFactory: - RDBMS: MySQL, version: 4.1.13a-nt
18:44:23,561  INFO SettingsFactory: - JDBC driver: MySQL-AB JDBC Driver, version: mysql-connector-java-3.1.10 ( $Date: 2005/05/19 15:52:23 $, $Revision: 1.1.2.2 $ )
18:44:23,561 DEBUG DriverManagerConnectionProvider: - returning connection to pool, pool size: 1
18:44:23,581  INFO Dialect: - Using dialect: org.hibernate.dialect.MySQLDialect
18:44:23,591  INFO TransactionFactoryFactory: - Using default transaction strategy (direct JDBC transactions)
18:44:23,591  INFO TransactionManagerLookupFactory: - No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
18:44:23,591  INFO SettingsFactory: - Automatic flush during beforeCompletion(): disabled
18:44:23,591  INFO SettingsFactory: - Automatic session close at end of transaction: disabled
18:44:23,591  INFO SettingsFactory: - JDBC batch size: 15
18:44:23,591  INFO SettingsFactory: - JDBC batch updates for versioned data: disabled
18:44:23,591  INFO SettingsFactory: - Scrollable result sets: enabled
18:44:23,591 DEBUG SettingsFactory: - Wrap result sets: disabled
18:44:23,591  INFO SettingsFactory: - JDBC3 getGeneratedKeys(): enabled
18:44:23,591  INFO SettingsFactory: - Connection release mode: auto
18:44:23,591  INFO SettingsFactory: - Maximum outer join fetch depth: 2
18:44:23,591  INFO SettingsFactory: - Default batch fetch size: 1
18:44:23,591  INFO SettingsFactory: - Generate SQL with comments: disabled
18:44:23,591  INFO SettingsFactory: - Order SQL updates by primary key: disabled
18:44:23,591  INFO SettingsFactory: - Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
18:44:23,601  INFO ASTQueryTranslatorFactory: - Using ASTQueryTranslatorFactory
18:44:23,601  INFO SettingsFactory: - Query language substitutions: {}
18:44:23,601  INFO SettingsFactory: - JPA-QL strict compliance: disabled
18:44:23,601  INFO SettingsFactory: - Second-level cache: enabled
18:44:23,601  INFO SettingsFactory: - Query cache: disabled
18:44:23,601  INFO SettingsFactory: - Cache provider: org.hibernate.cache.NoCacheProvider
18:44:23,601  INFO SettingsFactory: - Optimize cache for minimal puts: disabled
18:44:23,601  INFO SettingsFactory: - Structured second-level cache entries: disabled
18:44:23,601 DEBUG SQLExceptionConverterFactory: - Using dialect defined converter
18:44:23,601  INFO SettingsFactory: - Echoing all SQL to stdout
18:44:23,601  INFO SettingsFactory: - Statistics: disabled
18:44:23,601  INFO SettingsFactory: - Deleted entity synthetic identifier rollback: disabled
18:44:23,601  INFO SettingsFactory: - Default entity-mode: pojo
18:44:23,631  INFO SessionFactoryImpl: - building session factory
18:44:23,631 DEBUG SessionFactoryImpl: - Session factory constructed with filter configurations : {}
18:44:23,631 DEBUG SessionFactoryImpl: - instantiating session factory with properties: {java.runtime.name=Java(TM) 2 Runtime Environment, Standard Edition, hibernate.connection.password=root, sun.boot.library.path=C:\app\jdk1.5.0_02\jre\bin, java.vm.version=1.5.0_02-b09, hibernate.connection.username=root, java.vm.vendor=Sun Microsystems Inc., java.vendor.url=http://java.sun.com/, path.separator=;, java.vm.name=Java HotSpot(TM) Client VM, file.encoding.pkg=sun.io, user.country=US, sun.os.patch.level=Service Pack 2, java.vm.specification.name=Java Virtual Machine Specification, user.dir=C:\data\java5\examen\examenOneToOneTest, java.runtime.version=1.5.0_02-b09, java.awt.graphicsenv=sun.awt.Win32GraphicsEnvironment, java.endorsed.dirs=C:\app\jdk1.5.0_02\jre\lib\endorsed, os.arch=x86, java.io.tmpdir=C:\DOCUME~1\RaemdoP\LOCALS~1\Temp\, line.separator=
, java.vm.specification.vendor=Sun Microsystems Inc., user.variant=, os.name=Windows XP, sun.jnu.encoding=Cp1252, java.library.path=C:\app\jdk1.5.0_02\bin;.;C:\WINNT\system32;C:\WINNT;C:\Program Files\ThinkPad\Utilities;C:\WINNT\system32;C:\WINNT;C:\WINNT\System32\Wbem;C:\Program Files\Support Tools\;C:\Program Files\Intel\Wireless\Bin\;C:\Program Files\ATI Technologies\ATI Control Panel;C:\Program Files\Intel\Wireless\Bin\;C:\Program Files\Intel\Wireless\Bin\;C:\Program Files\Common Files\Ulead Systems\MPEG;C:\Program Files\Microsoft SQL Server\80\Tools\Binn\;C:\Program Files\Microsoft SQL Server\90\Tools\binn\;C:\Program Files\Microsoft SQL Server\90\DTS\Binn\;C:\Program Files\Microsoft SQL Server\90\Tools\Binn\VSShell\Common7\IDE\;C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\PrivateAssemblies\, java.specification.name=Java Platform API Specification, java.class.version=49.0, sun.management.compiler=HotSpot Client Compiler, os.version=5.1, user.home=C:\Documents and Settings\RaemdoP, connection.password=root, user.timezone=Europe/Paris, java.awt.printerjob=sun.awt.windows.WPrinterJob, connection.username=root, java.specification.version=1.5, file.encoding=Cp1252, hibernate.connection.driver_class=com.mysql.jdbc.Driver, show_sql=true, java.class.path=C:\data\java5\examen\examenOneToOneTest\bin;C:\data\java5\examen\examenOneToOneTest\lib\antlr-2.7.6.jar;C:\data\java5\examen\examenOneToOneTest\lib\asm.jar;C:\data\java5\examen\examenOneToOneTest\lib\asm-attrs.jar;C:\data\java5\examen\examenOneToOneTest\lib\cglib-2.1.3.jar;C:\data\java5\examen\examenOneToOneTest\lib\commons-collections-2.1.1.jar;C:\data\java5\examen\examenOneToOneTest\lib\commons-logging-1.0.4.jar;C:\data\java5\examen\examenOneToOneTest\lib\concurrent-1.3.2.jar;C:\data\java5\examen\examenOneToOneTest\lib\dom4j-1.6.1.jar;C:\data\java5\examen\examenOneToOneTest\lib\ehcache-1.2.3.jar;C:\data\java5\examen\examenOneToOneTest\lib\hibernate3.jar;C:\data\java5\examen\examenOneToOneTest\lib\jta.jar;C:\data\java5\examen\examenOneToOneTest\lib\log4j-1.2.11.jar;C:\data\java5\examen\examenOneToOneTest\lib\mysql-connector-java-3.1.10-bin.jar, user.name=RaemdoP, hibernate.bytecode.use_reflection_optimizer=false, hibernate.show_sql=true, java.vm.specification.version=1.0, sun.arch.data.model=32, java.home=C:\app\jdk1.5.0_02\jre, hibernate.connection.url=jdbc:mysql://localhost/hibtest, hibernate.dialect=org.hibernate.dialect.MySQLDialect, java.specification.vendor=Sun Microsystems Inc., user.language=en, awt.toolkit=sun.awt.windows.WToolkit, java.vm.info=mixed mode, java.version=1.5.0_02, java.ext.dirs=C:\app\jdk1.5.0_02\jre\lib\ext, sun.boot.class.path=C:\app\jdk1.5.0_02\jre\lib\rt.jar;C:\app\jdk1.5.0_02\jre\lib\i18n.jar;C:\app\jdk1.5.0_02\jre\lib\sunrsasign.jar;C:\app\jdk1.5.0_02\jre\lib\jsse.jar;C:\app\jdk1.5.0_02\jre\lib\jce.jar;C:\app\jdk1.5.0_02\jre\lib\charsets.jar;C:\app\jdk1.5.0_02\jre\classes, java.vendor=Sun Microsystems Inc., file.separator=\, connection.driver_class=com.mysql.jdbc.Driver, java.vendor.url.bug=http://java.sun.com/cgi-bin/bugreport.cgi, sun.cpu.endian=little, sun.io.unicode.encoding=UnicodeLittle, sun.desktop=windows, connection.url=jdbc:mysql://localhost/hibtest, sun.cpu.isalist=pentium_pro+mmx pentium_pro pentium+mmx pentium i486 i386 i86, dialect=org.hibernate.dialect.MySQLDialect}
18:44:23,762 DEBUG AbstractEntityPersister: - Static SQL for entity: cvo.test.Person
18:44:23,762 DEBUG AbstractEntityPersister: -  Version select: select uid from person where uid =?
18:44:23,762 DEBUG AbstractEntityPersister: -  Snapshot select: select person_.uid, person_.firstname as firstname0_ from person person_ where person_.uid=?
18:44:23,762 DEBUG AbstractEntityPersister: -  Insert 0: insert into person (firstname, uid) values (?, ?)
18:44:23,762 DEBUG AbstractEntityPersister: -  Update 0: update person set firstname=? where uid=?
18:44:23,762 DEBUG AbstractEntityPersister: -  Delete 0: delete from person where uid=?
18:44:23,762 DEBUG AbstractEntityPersister: - Static SQL for entity: cvo.test.Employee
18:44:23,762 DEBUG AbstractEntityPersister: -  Version select: select personid from employee where personid =?
18:44:23,762 DEBUG AbstractEntityPersister: -  Snapshot select: select employee_.personid, employee_.mailAddress as mailAddr2_1_ from employee employee_ where employee_.personid=?
18:44:23,762 DEBUG AbstractEntityPersister: -  Insert 0: insert into employee (mailAddress, personid) values (?, ?)
18:44:23,762 DEBUG AbstractEntityPersister: -  Update 0: update employee set mailAddress=? where personid=?
18:44:23,762 DEBUG AbstractEntityPersister: -  Delete 0: delete from employee where personid=?
18:44:23,782 DEBUG EntityLoader: - Static select for entity cvo.test.Person: select person0_.uid as uid0_0_, person0_.firstname as firstname0_0_ from person person0_ where person0_.uid=?
18:44:23,782 DEBUG EntityLoader: - Static select for entity cvo.test.Person: select person0_.uid as uid0_0_, person0_.firstname as firstname0_0_ from person person0_ where person0_.uid=?
18:44:23,892 DEBUG EntityLoader: - Static select for entity cvo.test.Person: select person0_.uid as uid0_0_, person0_.firstname as firstname0_0_ from person person0_ where person0_.uid=? for update
18:44:23,892 DEBUG EntityLoader: - Static select for entity cvo.test.Person: select person0_.uid as uid0_0_, person0_.firstname as firstname0_0_ from person person0_ where person0_.uid=? for update
18:44:23,892 DEBUG EntityLoader: - Static select for entity cvo.test.Person: select person0_.uid as uid0_0_, person0_.firstname as firstname0_0_ from person person0_ where person0_.uid=? for update
18:44:23,902 DEBUG EntityLoader: - Static select for action ACTION_MERGE on entity cvo.test.Person: select person0_.uid as uid0_0_, person0_.firstname as firstname0_0_ from person person0_ where person0_.uid=?
18:44:23,902 DEBUG EntityLoader: - Static select for action ACTION_REFRESH on entity cvo.test.Person: select person0_.uid as uid0_0_, person0_.firstname as firstname0_0_ from person person0_ where person0_.uid=?
18:44:23,902 DEBUG EntityLoader: - Static select for entity cvo.test.Employee: select employee0_.personid as personid1_1_, employee0_.mailAddress as mailAddr2_1_1_, person1_.uid as uid0_0_, person1_.firstname as firstname0_0_ from employee employee0_ left outer join person person1_ on employee0_.personid=person1_.uid where employee0_.personid=?
18:44:23,902 DEBUG EntityLoader: - Static select for entity cvo.test.Employee: select employee0_.personid as personid1_1_, employee0_.mailAddress as mailAddr2_1_1_, person1_.uid as uid0_0_, person1_.firstname as firstname0_0_ from employee employee0_ left outer join person person1_ on employee0_.personid=person1_.uid where employee0_.personid=?
18:44:23,902 DEBUG EntityLoader: - Static select for entity cvo.test.Employee: select employee0_.personid as personid1_0_, employee0_.mailAddress as mailAddr2_1_0_ from employee employee0_ where employee0_.personid=? for update
18:44:23,902 DEBUG EntityLoader: - Static select for entity cvo.test.Employee: select employee0_.personid as personid1_0_, employee0_.mailAddress as mailAddr2_1_0_ from employee employee0_ where employee0_.personid=? for update
18:44:23,902 DEBUG EntityLoader: - Static select for entity cvo.test.Employee: select employee0_.personid as personid1_0_, employee0_.mailAddress as mailAddr2_1_0_ from employee employee0_ where employee0_.personid=? for update
18:44:23,902 DEBUG EntityLoader: - Static select for action ACTION_MERGE on entity cvo.test.Employee: select employee0_.personid as personid1_1_, employee0_.mailAddress as mailAddr2_1_1_, person1_.uid as uid0_0_, person1_.firstname as firstname0_0_ from employee employee0_ left outer join person person1_ on employee0_.personid=person1_.uid where employee0_.personid=?
18:44:23,902 DEBUG EntityLoader: - Static select for action ACTION_REFRESH on entity cvo.test.Employee: select employee0_.personid as personid1_1_, employee0_.mailAddress as mailAddr2_1_1_, person1_.uid as uid0_0_, person1_.firstname as firstname0_0_ from employee employee0_ left outer join person person1_ on employee0_.personid=person1_.uid where employee0_.personid=?
18:44:23,902 DEBUG SessionFactoryObjectFactory: - initializing class SessionFactoryObjectFactory
18:44:23,902 DEBUG SessionFactoryObjectFactory: - registered: 4028fbf70f9bd067010f9bd0685e0000 (unnamed)
18:44:23,902  INFO SessionFactoryObjectFactory: - Not binding factory to JNDI, no JNDI name configured
18:44:23,902 DEBUG SessionFactoryImpl: - instantiated session factory
18:44:23,902 DEBUG SessionFactoryImpl: - Checking 0 named HQL queries
18:44:23,902 DEBUG SessionFactoryImpl: - Checking 0 named SQL queries
18:44:24,002 DEBUG SessionImpl: - opened session at timestamp: 11665502639
18:44:24,002 DEBUG JDBCTransaction: - begin
18:44:24,002 DEBUG ConnectionManager: - opening JDBC connection
18:44:24,002 DEBUG DriverManagerConnectionProvider: - total checked-out connections: 0
18:44:24,012 DEBUG DriverManagerConnectionProvider: - using pooled JDBC connection, pool size: 0
18:44:24,012 DEBUG JDBCTransaction: - current autocommit status: false
18:44:24,012 DEBUG JDBCContext: - after transaction begin
18:44:24,012 DEBUG IdentifierValue: - id unsaved-value: null
18:44:24,012 DEBUG AbstractSaveEventListener: - detached instance of: cvo.test.Employee
18:44:24,012 DEBUG DefaultSaveOrUpdateEventListener: - updating detached instance
18:44:24,012 DEBUG SerializationHelper: - Starting serialization of object [[Person: uid: 10 firstname: pieter]]
18:44:24,032 DEBUG DefaultSaveOrUpdateEventListener: - updating [cvo.test.Employee#2c6d8085f3f2808fe3f6efaef4e5f3f4aed0e5f2f3efee8080808080808081828082cc8089e6e9f2f3f4eee1ede5f48092cceae1f6e1afece1eee7afd3f4f2e9eee7bbcc8083f5e9e4f48093cceae1f6e1afece1eee7afc9eef4e5e7e5f2bbf8f0f48086f0e9e5f4e5f2f3f28091eae1f6e1aeece1eee7aec9eef4e5e7e5f292622024770107b8828081c98085f6e1ecf5e5f8f28090eae1f6e1aeece1eee7aecef5ede2e5f2062c159d8b14600b828080f8f08080808a]
18:44:24,042 DEBUG SerializationHelper: - Starting serialization of object [[Person: uid: 10 firstname: pieter]]
18:44:24,042 DEBUG SerializationHelper: - Starting serialization of object [[Person: uid: 10 firstname: pieter]]
18:44:24,042 DEBUG DefaultSaveOrUpdateEventListener: - updating [cvo.test.Employee#2c6d8085f3f2808fe3f6efaef4e5f3f4aed0e5f2f3efee8080808080808081828082cc8089e6e9f2f3f4eee1ede5f48092cceae1f6e1afece1eee7afd3f4f2e9eee7bbcc8083f5e9e4f48093cceae1f6e1afece1eee7afc9eef4e5e7e5f2bbf8f0f48086f0e9e5f4e5f2f3f28091eae1f6e1aeece1eee7aec9eef4e5e7e5f292622024770107b8828081c98085f6e1ecf5e5f8f28090eae1f6e1aeece1eee7aecef5ede2e5f2062c159d8b14600b828080f8f08080808a]
18:44:24,052 DEBUG Cascade: - processing cascade ACTION_SAVE_UPDATE for: cvo.test.Employee
18:44:24,052 DEBUG CascadingAction: - cascading to saveOrUpdate: cvo.test.Person
18:44:24,052 DEBUG IdentifierValue: - id unsaved-value strategy UNDEFINED
18:44:24,052 DEBUG AbstractEntityPersister: - Getting current persistent state for: [cvo.test.Person#10]
18:44:24,052 DEBUG AbstractBatcher: - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
18:44:24,052 DEBUG SQL: - select person_.uid, person_.firstname as firstname0_ from person person_ where person_.uid=?
Hibernate: select person_.uid, person_.firstname as firstname0_ from person person_ where person_.uid=?
18:44:24,052 DEBUG AbstractBatcher: - preparing statement
18:44:24,142 DEBUG IntegerType: - binding '10' to parameter: 1
18:44:24,152 DEBUG AbstractBatcher: - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
18:44:24,152 DEBUG AbstractBatcher: - closing statement
18:44:24,152 DEBUG AbstractSaveEventListener: - transient instance of: cvo.test.Person
18:44:24,152 DEBUG DefaultSaveOrUpdateEventListener: - saving transient instance
18:44:24,152 DEBUG AbstractSaveEventListener: - generated identifier: 10, using strategy: org.hibernate.id.Assigned
18:44:24,152 DEBUG AbstractSaveEventListener: - saving [cvo.test.Person#10]
18:44:24,162 DEBUG Cascade: - done processing cascade ACTION_SAVE_UPDATE for: cvo.test.Employee
18:44:24,162 DEBUG JDBCTransaction: - commit
18:44:24,162 DEBUG SessionImpl: - automatically flushing session
18:44:24,162 DEBUG AbstractFlushingEventListener: - flushing session
18:44:24,162 DEBUG AbstractFlushingEventListener: - processing flush-time cascades
18:44:24,162 DEBUG Cascade: - processing cascade ACTION_SAVE_UPDATE for: cvo.test.Employee
18:44:24,162 DEBUG CascadingAction: - cascading to saveOrUpdate: cvo.test.Person
18:44:24,162 DEBUG AbstractSaveEventListener: - persistent instance of: cvo.test.Person
18:44:24,162 DEBUG DefaultSaveOrUpdateEventListener: - ignoring persistent instance
18:44:24,162 DEBUG DefaultSaveOrUpdateEventListener: - object already associated with session: [cvo.test.Person#10]
18:44:24,162 DEBUG Cascade: - done processing cascade ACTION_SAVE_UPDATE for: cvo.test.Employee
18:44:24,162 DEBUG AbstractFlushingEventListener: - dirty checking collections
18:44:24,162 DEBUG AbstractFlushingEventListener: - Flushing entities and processing referenced collections
18:44:24,162 DEBUG SerializationHelper: - Starting serialization of object [[Person: uid: 10 firstname: pieter]]
18:44:24,162 DEBUG SerializationHelper: - Starting serialization of object [[Person: uid: 10 firstname: pieter]]
18:44:24,162 DEBUG DefaultFlushEntityEventListener: - Updating entity: [cvo.test.Employee#2c6d8085f3f2808fe3f6efaef4e5f3f4aed0e5f2f3efee8080808080808081828082cc8089e6e9f2f3f4eee1ede5f48092cceae1f6e1afece1eee7afd3f4f2e9eee7bbcc8083f5e9e4f48093cceae1f6e1afece1eee7afc9eef4e5e7e5f2bbf8f0f48086f0e9e5f4e5f2f3f28091eae1f6e1aeece1eee7aec9eef4e5e7e5f292622024770107b8828081c98085f6e1ecf5e5f8f28090eae1f6e1aeece1eee7aecef5ede2e5f2062c159d8b14600b828080f8f08080808a]
18:44:24,162 DEBUG AbstractFlushingEventListener: - Processing unreferenced collections
18:44:24,162 DEBUG AbstractFlushingEventListener: - Scheduling collection removes/(re)creates/updates
18:44:24,162 DEBUG AbstractFlushingEventListener: - Flushed: 1 insertions, 1 updates, 0 deletions to 2 objects
18:44:24,162 DEBUG AbstractFlushingEventListener: - Flushed: 0 (re)creations, 0 updates, 0 removals to 0 collections
18:44:24,162 DEBUG Printer: - listing entities:
18:44:24,172 DEBUG Printer: - cvo.test.Person{firstname=pieter, uid=10}
18:44:24,172 DEBUG SerializationHelper: - Starting serialization of object [[Person: uid: 10 firstname: pieter]]
18:44:24,172 DEBUG Printer: - cvo.test.Employee{mailAddress=pieter.raemdonck@pfizer.com, person=cvo.test.Person#10}
18:44:24,172 DEBUG AbstractFlushingEventListener: - executing flush
18:44:24,172 DEBUG ConnectionManager: - registering flush begin
18:44:24,172 DEBUG AbstractEntityPersister: - Inserting entity: [cvo.test.Person#10]
18:44:24,172 DEBUG AbstractBatcher: - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
18:44:24,172 DEBUG SQL: - insert into person (firstname, uid) values (?, ?)
Hibernate: insert into person (firstname, uid) values (?, ?)
18:44:24,172 DEBUG AbstractBatcher: - preparing statement
18:44:24,172 DEBUG AbstractEntityPersister: - Dehydrating entity: [cvo.test.Person#10]
18:44:24,172 DEBUG StringType: - binding 'pieter' to parameter: 1
18:44:24,172 DEBUG IntegerType: - binding '10' to parameter: 2
18:44:24,172 DEBUG AbstractBatcher: - Executing batch size: 1
18:44:24,172 DEBUG AbstractBatcher: - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
18:44:24,172 DEBUG AbstractBatcher: - closing statement
18:44:24,172 DEBUG SerializationHelper: - Starting serialization of object [[Person: uid: 10 firstname: pieter]]
18:44:24,172 DEBUG AbstractEntityPersister: - Updating entity: [cvo.test.Employee#2c6d8085f3f2808fe3f6efaef4e5f3f4aed0e5f2f3efee8080808080808081828082cc8089e6e9f2f3f4eee1ede5f48092cceae1f6e1afece1eee7afd3f4f2e9eee7bbcc8083f5e9e4f48093cceae1f6e1afece1eee7afc9eef4e5e7e5f2bbf8f0f48086f0e9e5f4e5f2f3f28091eae1f6e1aeece1eee7aec9eef4e5e7e5f292622024770107b8828081c98085f6e1ecf5e5f8f28090eae1f6e1aeece1eee7aecef5ede2e5f2062c159d8b14600b828080f8f08080808a]
18:44:24,172 DEBUG AbstractBatcher: - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
18:44:24,172 DEBUG SQL: - update employee set mailAddress=? where personid=?
Hibernate: update employee set mailAddress=? where personid=?
18:44:24,172 DEBUG AbstractBatcher: - preparing statement
18:44:24,222 DEBUG SerializationHelper: - Starting serialization of object [[Person: uid: 10 firstname: pieter]]
18:44:24,232 DEBUG AbstractEntityPersister: - Dehydrating entity: [cvo.test.Employee#2c6d8085f3f2808fe3f6efaef4e5f3f4aed0e5f2f3efee8080808080808081828082cc8089e6e9f2f3f4eee1ede5f48092cceae1f6e1afece1eee7afd3f4f2e9eee7bbcc8083f5e9e4f48093cceae1f6e1afece1eee7afc9eef4e5e7e5f2bbf8f0f48086f0e9e5f4e5f2f3f28091eae1f6e1aeece1eee7aec9eef4e5e7e5f292622024770107b8828081c98085f6e1ecf5e5f8f28090eae1f6e1aeece1eee7aecef5ede2e5f2062c159d8b14600b828080f8f08080808a]
18:44:24,232 DEBUG StringType: - binding 'pieter.raemdonck@pfizer.com' to parameter: 1
18:44:24,232 DEBUG SerializationHelper: - Starting serialization of object [[Person: uid: 10 firstname: pieter]]
18:44:24,232 DEBUG SerializableType: - binding '2c6d8085f3f2808fe3f6efaef4e5f3f4aed0e5f2f3efee8080808080808081828082cc8089e6e9f2f3f4eee1ede5f48092cceae1f6e1afece1eee7afd3f4f2e9eee7bbcc8083f5e9e4f48093cceae1f6e1afece1eee7afc9eef4e5e7e5f2bbf8f0f48086f0e9e5f4e5f2f3f28091eae1f6e1aeece1eee7aec9eef4e5e7e5f292622024770107b8828081c98085f6e1ecf5e5f8f28090eae1f6e1aeece1eee7aecef5ede2e5f2062c159d8b14600b828080f8f08080808a' to parameter: 2
18:44:24,232 DEBUG SerializationHelper: - Starting serialization of object [[Person: uid: 10 firstname: pieter]]
18:44:24,232 DEBUG AbstractBatcher: - Executing batch size: 1
18:44:24,232 ERROR AbstractBatcher: - Exception executing batch:
org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1
   at org.hibernate.jdbc.Expectations$BasicExpectation.checkBatched(Expectations.java:61)
   at org.hibernate.jdbc.Expectations$BasicExpectation.verifyOutcome(Expectations.java:46)
   at org.hibernate.jdbc.BatchingBatcher.checkRowCounts(BatchingBatcher.java:68)
   at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:48)
   at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:242)
   at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:235)
   at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:140)
   at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298)
   at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
   at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
   at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338)
   at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
   at cvo.test.Main.main(Main.java:20)
18:44:24,232 DEBUG AbstractBatcher: - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
18:44:24,242 DEBUG AbstractBatcher: - closing statement
18:44:24,242 ERROR AbstractFlushingEventListener: - Could not synchronize database state with session
org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1
   at org.hibernate.jdbc.Expectations$BasicExpectation.checkBatched(Expectations.java:61)
   at org.hibernate.jdbc.Expectations$BasicExpectation.verifyOutcome(Expectations.java:46)
   at org.hibernate.jdbc.BatchingBatcher.checkRowCounts(BatchingBatcher.java:68)
   at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:48)
   at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:242)
   at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:235)
   at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:140)
   at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298)
   at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
   at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
   at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338)
   at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
   at cvo.test.Main.main(Main.java:20)
18:44:24,242 DEBUG ConnectionManager: - registering flush end
Exception in thread "main" org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1
   at org.hibernate.jdbc.Expectations$BasicExpectation.checkBatched(Expectations.java:61)
   at org.hibernate.jdbc.Expectations$BasicExpectation.verifyOutcome(Expectations.java:46)
   at org.hibernate.jdbc.BatchingBatcher.checkRowCounts(BatchingBatcher.java:68)
   at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:48)
   at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:242)
   at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:235)
   at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:140)
   at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298)
   at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
   at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
   at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338)
   at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
   at cvo.test.Main.main(Main.java:20)


Top
 Profile  
 
 Post subject: solved
PostPosted: Tue Dec 19, 2006 2:56 pm 
Newbie

Joined: Sat Dec 16, 2006 6:19 pm
Posts: 3
I have solved it myself. I thought that hibernate would pick up the id from the person object itself. But it seems that it does not. So I have created an addtional id field for the employee class.

Employee.java
Code:
package cvo.test;

import java.io.Serializable;

public class Employee implements Serializable {

   
   private static final long serialVersionUID = 1L;
   
   private Integer uid;

   private Person person;

   private String mailAddress;

   public Employee() {
      super();
   }

   public Employee(Integer uid, Person person, String mailAddress) {
      super();
      this.uid = uid;
      this.person = person;
      this.mailAddress = mailAddress;
   }
   
   public Employee(Person person, String mailAddress) {
      super();
      this.person = person;
      this.mailAddress = mailAddress;
   }
   
   public Employee(Integer id, String firstname, String mailAddress) {
      super();
      this.person = new Person(id, firstname);
      this.mailAddress = mailAddress;
   }

   public Integer getUid() {
      return uid;
   }

   public void setUid(Integer uid) {
      this.uid = uid;
   }

   public String getMailAddress() {
      return mailAddress;
   }

   public void setMailAddress(String mailAddress) {
      this.mailAddress = mailAddress;
   }

   public Person getPerson() {
      return person;
   }

   public void setPerson(Person person) {
      this.person = person;
   }

   public String toString() {
      StringBuffer buffer = new StringBuffer();
      buffer.append("[Employee:");
      buffer.append(" uid: ");
      buffer.append(uid);
      buffer.append(" person: ");
      buffer.append(person);
      buffer.append(" mailAddress: ");
      buffer.append(mailAddress);
      buffer.append("]");
      return buffer.toString();
   }

   
   public boolean equals(Object o) {
      if (this == o) {
         return true;
      }
      if (o == null) {
         return false;
      }
      if (o.getClass() != getClass()) {
         return false;
      }
      Employee castedObj = (Employee) o;
      return ((this.uid == null ? castedObj.uid == null : this.uid
         .equals(castedObj.uid))
         && (this.person == null ? castedObj.person == null : this.person
            .equals(castedObj.person)) && (this.mailAddress == null
         ? castedObj.mailAddress == null
         : this.mailAddress.equals(castedObj.mailAddress)));
   }



}


Employee.hbm.xml
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="cvo.test">
   <class name="Employee" table="employee" lazy="false">
      <id name="uid" column="uid">
         <generator class="foreign">
           <param name="property">person</param>
         </generator>
      </id>
      <property name="mailAddress" column="mailAddress"/>
      <one-to-one name="person" class="Person" cascade="all" constrained="true"/>
   </class>
</hibernate-mapping>


sql
Code:

DROP TABLE IF EXISTS `person`;
CREATE TABLE `person` (
  `uid` int(10) unsigned NOT NULL default '0',
  `firstname` varchar(50) NOT NULL default '',
  PRIMARY KEY  (`uid`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

DROP TABLE IF EXISTS `employee`;
CREATE TABLE `employee` (
  `uid` int(10) unsigned NOT NULL default '0',
  `mailAddress` varchar(45) NOT NULL default '',
  PRIMARY KEY  (`uid`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ;


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.