Hi there,
I have a peculiar problem with Hibernate JPA. I seem to be unable to put an embedded entity into a secondary table.
Here is a such an entity definition (put into orm.xml):
Code:
<entity class="example.Foo" name="Foo" access="PROPERTY">
<table name="tbl_foo"/>
<secondary-table name="tbl_foo_desc">
<primary-key-join-column name="c_foo"/>
</secondary-table>
<secondary-table name="tbl_foo_bar">
<primary-key-join-column name="c_foo"/>
</secondary-table>
<attributes>
<id name="id">
<column name="c_id" nullable="false" updatable="false"/>
<generated-value strategy="TABLE" generator="Foo"/>
<table-generator name="Foo"
table="tbl_jpa_seq_gen"
pk-column-name="c_entity"
value-column-name="c_count"
pk-column-value="Foo"/>
</id>
<basic name="name">
<column name="c_name" length="255"/>
</basic>
<basic name="description" fetch="LAZY">
<column name="c_description" table="tbl_foo_desc" length="65536"/>
</basic>
<embedded name="bar">
<attribute-override name="info">
<column name="c_info" table="tbl_foo_bar" nullable="false" updatable="false"/>
</attribute-override>
<attribute-override name="context">
<column name="c_context" table="tbl_foo_bar" nullable="false" updatable="false"/>
</attribute-override>
</embedded>
</attributes>
</entity>
And here is the definition of the embeddable in the same file:
Code:
<embeddable class="example.Bar" access="PROPERTY">
<attributes>
<basic name="info">
<column name="c_info"/>
</basic>
<basic name="context">
<column name="c_context"/>
</basic>
</attributes>
</embeddable>
When I try to deploy this I get the following error:
Quote:
Binding entity from annotated class: example.Foo
Bind entity example.Foo on table tbl_foo
Adding secondary table to entity example.Foo -> tbl_foo_desc
Adding secondary table to entity example.Foo -> tbl_foo_bar
A component cannot hold properties split into 2 different tables: example.Foo.bar
org.hibernate.AnnotationException: A component cannot hold properties split into 2 different tables: example.Foo.bar
<omitted stack trace>
Am I trying to do something that is not permitted? Any help would be much appreciated.
I am using Hibernate JPA 3.4.0 available via the Glassfish update center.