This week's book giveaway is in the
We're giving away four copies of
Head First Android
and have Dawn & David Griffiths on-line!
A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Win a copy of
Head First Android
this week in the
Object Relational Mapping
Hibernate - Mapping 1 column to multiple properties
Joined: Oct 25, 2004
Oct 25, 2004 15:50:00
I am attempting to map a database column to two properties in a hibernate object (see example below). One of those properties is "read-only".
I would like a foreign key ID column to map to both a property for the ID and a property for the object represented in the foreign key table.
See "property_id" column below in the example. I have marked the mapped property as "insert=false" and "update=false" so you cannot set these values in code.
Unfortunately, Hibernate does not seem to handle this situation. There never is a value for the "property" object. Is this unsupported or am I missing something obvious?
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//EN"
<class name="UTDocPropertyValue" table="doc_property_value" lazy="true">
<id name="id" column="doc_property_value_id">
<generator class="native" />
<property name="documentId" column="document_id" />
<property name="propertyId" column="property_id" />
<property name="propertyValue" column="doc_property_value" />
<many-to-one name="property" column="property_id" insert="false" update="false" class="UTProperty" />
I agree. Here's the link:
subject: Hibernate - Mapping 1 column to multiple properties
persisting a collection - one-to-many mapping
many-to-one relationship to non-PK field
Exception when having different class and table name
1-to-M mapping confusion
Hibernate - Force foreign key lookup on insert
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2015