Hi,
I have the following simple situation:
Two classes who has a one-to-one relationship.
Class Component generates the key for class Currency.
When I store an Object of the Component class type, hibernate only stores the component in the component table, but he doesn't store anything in the currency table.
Can somebody help me with this?
Here's my code:
Code:
<hibernate-mapping>
<class
name="logic.Component"
table="COMPONENT">
<id
name="id"
column="ID"
type="java.lang.Long"
unsaved-value="null">
<generator class="native"/>
</id>
...
<one-to-one name="price"/>
...
</class>
</hibernate-mapping>
Code:
<hibernate-mapping>
<class
name="logic.Currency"
table="CURRENCY">
<id
name="id"
column="ID"
type="long">
<generator class="assigned">
</generator>
</id>
...
<one-to-one
name="component"
class="logic.Component"
constrained="true"
foreign-key="componentfk"/>
</class>
</hibernate-mapping>
Code:
public abstract class Component extends Persistent implements Serializable {
protected String name;
private String description;
private Blob photo = null;
protected Currency price;
protected boolean selected;
protected List children;
protected CompositeComponent parent;
...
Code:
public class Currency extends Persistent{
private double amount;
private int moneyType;
public double exchangeRates[];
private Component component;
...
That's the last thing hibernate prints in the console:
Code:
22:25:17,937 INFO DriverManagerConnectionProvider:143 - cleaning up connection pool: jdbc:mysql://127.0.0.1:3306/carco
Hibernate: insert into COMPONENT (NAME, DESCRIPTION, PHOTO, PARENT, DISCRIMINATOR) values (?, ?, ?, ?, 'stdcomposite')
Like you can see, he doesn't insert anything in the currency table.
Thanks in advance ...