Hi everyone,
I'm having a problem when I want to insert something in my database.
Here are the two java classes I'd like to save in database :
Source code :
Code:
package com.myPackage;
import java.io.Serializable;
public class MyClassA implements Serializable{
private static final long serialVersionUID = -8832112548535849481L;
private long id;
private MyclassB myclassB;
public MyClassA(){
super();
}
public long getid() {
return id;
}
public void setId(long id) {
this.id = id;
}
public long getMyclassB() {
return myclassB;
}
public void setMyclassB(long myclassB){
this.myclassB = myclassB;
}
}
Code:
package com.myPackage;
import java.io.Serializable;
public class MyClassB implements Serializable{
private static final long serialVersionUID = -8812584561535849481L;
private long id;
private String myField;
public MyClassB(){
super();
}
public long getid() {
return id;
}
public void setId(long id) {
this.id = id;
}
public long getMyField() {
return myField;
}
public void setMyField(long myField){
this.myField = myField;
}
}
Hibernate mapping :
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate mapping DTD 3.0//EN"
"packages/resources/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="com.myPackage">
<class name="MyClassA" table="MYCLASSA" lazy="false">
<id name="id" type="long">
<generator class="sequence">
<param name="sequence">ssr_id_seq</param>
</generator>
</id>
<one-to-one name="myClassB" column="MYCLASSB_FK" class="com.myPackage.MyClassB" cascade="all"/>
</class>
</hibernate-mapping>
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate mapping DTD 3.0//EN"
"packages/resources/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="com.myPackage">
<class name="MyClassB" table="MYCLASSB" lazy="false">
<id name="id" type="long">
<generator class="sequence">
<param name="sequence">pm_id_seq</param>
</generator>
</id>
<property name="myField" type="java.lang.String">
<column name="MyField" not-null="true" unique="false" sql-type="VARCHAR2(255)"/>
</property>
</class>
</hibernate-mapping>
When I want to save "MyClassA", log files tells me that it has been trying to update "MYCLASSA", but there is nothing to update in DB, while I want the application to
insert MYCLASSA (and indeed MYCLASSB) in DB.
Here is my configuration:
Hibernate : 3.0
Database : Oracle 10.2.0.3
Web server : Jonas 4.8.4
IDE : Eclipse 3.4.1
Struts application
Can anybody help me ?
Thanks