[
http://opensource.atlassian.com/projects/hibernate/browse/HHH-3824?page=c...
]
Trevor Baker updated HHH-3824:
------------------------------
Attachment: HHH-3824.zip
Hi,
I've attached a test case to highlight this issue. Just run: mvn test
Really the issue should be renamed to @OneToOne( mappedBy ) ignores mappedBy's
@JoinColumn( referenceColumnName )
You'll see:
Hibernate: select parent2x0_.id as id10_1_, parent2x0_.uniqueId as uniqueId10_1_,
child2x1_.id as id11_0_, child2x1_.parentIdFK as parentIdFK11_0_ from Parent2 parent2x0_
left outer join Child2 child2x1_ on *parent2x0_.id=child2x1_.parentIdFK* where
parent2x0_.uniqueId=?
This is because in org.hibernate.type.OneToOneType the lhs is always the PK.
thanks,
Trev
OneToOne join by Non-primary key column throws
PropertyAccessException when join column is String
-------------------------------------------------------------------------------------------------
Key: HHH-3824
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-3824
Project: Hibernate Core
Issue Type: Bug
Components: query-criteria, query-hql
Affects Versions: 3.3.1
Environment: Microsoft SQL server 2005, Hibernate 3.3.1
Reporter: sathish
Assignee: Sharath Reddy
Attachments: HHH-3824.zip, hibernate-3.5.0-beta-3-annotations.patch,
hibernate-3.5.0-beta-3-core.patch, trace.txt
When i try to join 2 entities by OneToOne using a Non-primary key column, it throws the
following exception:
org.hibernate.PropertyAccessException: could not get a field value by reflection getter
of com.xxx.domain.Inventory.sku
Caused by: java.lang.IllegalArgumentException: Can not set java.lang.String field
com.inwk.estore.server.domain.Inventory.sku to java.lang.Integer
[Full stacktrace attached]
sku is the Non-primary key String join column by which im trying to do a OneToOne join
between Item and Inventory entity.
Apparently its trying to interpret Sku as an Integer column. Adding columnDefinition as
VARCHAR/String doesn't help either
Mappings for Item and Inventory are below:
class Item{
@Id
Long id;
@Column
String sku;
//some more properties
@OneToOne(optional = true)
@JoinColumn(name = "sku", referencedColumnName = "sku", insertable =
false, updatable = false)
Inventory inventory;
}
class Inventory{
@Id
Long id
@Column
String sku
@Column
Long quantity;
}
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira