I'm having to map hibernate in some unorthodox ways to an existing database schema that cannot be modified, and have run into a problem with hibernate not issuing any update or insert statements for a relationship.
I have two tables:
Code:
webConsumer {
ConsumerID INT IDENTITY(1,1) NOT NULL,
...
}
with consumer_id as its primary key.
Then another table that holds various other information for WebConsumers:
Code:
webAttribute {
ConsumerID INT NOT NULL,
AttributeValueTag VARCHAR(50) NOT NULL,
AttrValue VARCHAR(100) NULL
}
webAttribute has a unique constraint on consumer_id, AttributeValueTag with a foreign key constraint on consumer_id.
I have some properties stored in webAttribute that are many-to-one with webConsumer but I just want a list of strings from the AttributeValueTag column from the webAttribute table, and I don't want to have to code a set of webAttribute objects with composite keys to update this list of strings.
The relevant part of my WebConsumer xml is this:
Code:
<bag name="propertyTypes" inverse="true" table="vw_Types_Properties"
cascade="all, delete-orphan" lazy="false">
<key>
<column name="ConsumerID" not-null="true" />
</key>
<element type="java.lang.String" column="AttributeValueTag" unique="true" />
</bag>
Where the table "vw_Types_Properties" is just a view of webAttributes where AttributeValueTag LIKE 'Property%'.
This mapping issues the correct select statement and gets the data great as a List property (returns a list of strings that came from the AttributeValueTag field). The java object even adds and removes items from the list in memory but when I use a corresponding dao to save the data hibernate does not issue any INSERT or UPDATE sql at all.
I'm using <join><property .../> tags elsewhere with <sql-insert>...</sql-insert> for some one-to-one properties in the same table, which work great but now I need to do the same sort of thing as a one-to-many, and I'm stumped.
Any help would be greatly appreciated!