]
Steve Ebersole closed HHH-1165.
-------------------------------
Closing stale resolved issues
Bidirectional many-to-one fails to write the sort column when the
collection is a list
--------------------------------------------------------------------------------------
Key: HHH-1165
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-1165
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.1 rc2
Environment: Any
Reporter: Rich MacDonald
Below is the Person-Address example from the manual adapted to a list collection.
<class name="Person">
<id name="id" column="personId">
<generator class="native"/>
</id>
<many-to-one name="address" column="addressId"
not-null="true"/>
</class>
<class name="Address">
<id name="id" column="addressId">
<generator class="native"/>
</id>
<list name="people" inverse="true">
<key column="addressId"/>
<list-index column="sortOrder"/>
<one-to-many class="Person"/>
</list>
</class>
In my real application, I require this association to be nullable, since it is part of a
table-per-hierarchy mapping. IOW, the Person.addressId and sortOrder column must be
nullable. This is irrelevant to the bug, which occurs whether or not the not-null in
<many-to-one name="address" column="addressId"
not-null="true"/> is true or false.
The database schema is (firebird format):
create table Address (addressId numeric(18,0) not null, primary key (addressId))
create table Person (personId numeric(18,0) not null, addressId numeric(18,0) not null,
sortOrder integer, primary key (personId))
alter table Person add constraint FK8E488775A940C75F foreign key (addressId) references
Address
Note in table Person that addressId is not null, while sortOrder is nullable. That is a
bug. Should also be a uniqueness constraint on addressId+sortOrder.
Create a few objects, fill the association, and save it. You should find that the
"sortOrder" column has null values. From the logging:
insert into Person (addressId, personId) values (?, ?)
Hibernate: insert into Person (addressId, personId) values (?, ?)
Dehydrating entity: [example.Person#3]
LongType:79 - binding '1' to parameter: 1
LongType:79 - binding '3' to parameter: 2
Naturally, when the data is read back from the database, the app will fail because it
cannot handle a nulled sortOrder.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: