[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [eclipselink-users] possible bug with Embeddables using ManyToOne?
|
Tom,
Thanks for the suggestion, the table name fixed it! I had tried that
before, but mistakenly used table="product" rather than
table="cust_order", which was the wrong mapping.
Removing referencedColumnName had no effect... my original example
didn't use it, but I'd added that as an attempt to fix it.
I've discovered that this or a similar bug manifests in 2.2 as well, but
only if I use a single @Embedded rather than @ElementCollection:
@Entity
@Table(name = "customer", schema = "ELTEST")
public class Customer
{
@Id
@Column(name = "cust_id")
Integer id;
@Embedded
@JoinColumn(name = "cust_id")
CustomerOrder order;
}
However, setting table on the @ManyToOne also corrected this. I'll file
a bug.
On 03/16/2012 02:31 PM, Tom Ware wrote:
Another thing to try:
It looks like referencedColumnName is pointing to the default. Try
removing the specific reference to it since we should be picking that
column by default.
On 16/03/2012 2:25 PM, Tom Ware wrote:
Hi Todd,
Please file a bug.
What happens if you set the table on your join column?
-Tom
On 16/03/2012 1:46 PM, Todd Perry wrote:
Hello,
We are looking at EclipseLink as an ORM solution for a new project,
so I was
trying to adapt one of our existing mappings (using Hibernate) and
ran into what
looks like a bug in the 2.3.2 release.
If I take the following test entities:
@Entity
@Table(name = "product", schema = "ELTEST")
public class Product
{
@Id
@Column(name = "product_id")
Integer id;
}
@Embeddable
public class CustomerOrder
{
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "product_id", referencedColumnName = "product_id")
Product product;
}
@Entity
@Table(name = "customer", schema = "ELTEST")
public class Customer
{
@Id
@Column(name = "cust_id")
Integer id;
@ElementCollection(fetch = FetchType.LAZY)
@CollectionTable(name = "cust_order",
joinColumns = @JoinColumn(name = "cust_id"))
List<CustomerOrder> orders = new ArrayList<CustomerOrder>();
}
Version 2.3.2 throws an exception:
Exception [EclipseLink-93] (Eclipse Persistence Services -
2.3.2.v20111125-r10461):
org.eclipse.persistence.exceptions.DescriptorException
Exception Description: The table [cust_order] is not present in this
descriptor.
Descriptor: RelationalDescriptor(com.vtls.domain.test.Product -->
[DatabaseTable(ELTEST.product)])
From some debugging, it appears that the both the source and target
fields in
the ManyToOne mapping in CustomerOrder is being set to
cust_order.product_id,
causing it to look for the wrong table descriptor when processing
foreign keys.
The real target field name should be product.product_id. This seems
to be
messing up at some post-processing step, because when I check the
original
ManyToOneMapping created, it is using the proper field name
(product.product_id)
for the target.
I tried the previous 2.2.1 release, and this problem doesn't happen.
I also discovered that if I change the mapping so the join column
name doesn't
match the target column name:
@JoinColumn(name = "linked_product_id", referencedColumnName =
"product_id")
It works in both releases. Unfortunately I can't do this in our
production
system since the schema is already created and in use. The problem
only seems to
happen if the owner of the OneToMany relationship is an Embeddable,
not an
Entity.
I'm pretty sure this is a bug and haven't been able to find anything
similer in
Bugzillla, but I wanted to be sure before entering a new one.
_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users
_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users