[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [eclipselink-users] Duplicate column name with @Embedded and @AttributeOverrides
|
Very odd. Are you using the latest release (or can you try the latest
release)?
It might have something to do with your defaulting of the Embeddable.
>> protected RegistrationStatus jbackupStatus = RegistrationStatus.UNKNOWN;
This is not good, as all objects will share the exact same embeddable, but
they should each have their own unique copy. Otherwise a change to one of
them, will affect them all. Try using,
protected RegistrationStatus jbackupStatus = new
RegistrationStatus(UNKNOWN);
Definitely seems similar to the bug you referenced. Perhaps include your
information in the bug and vote for it. Try to include an isolated test
case.
Pavel Arnost wrote:
>
> Hi,
>
> I have a strange problem with @Embedded and @AttributeOverrides resulting
> in "duplicate column name" SQL error. It's similar to
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=328307.
>
> Embeddable class:
>
> @Embeddable
> public class RegistrationStatus {
> public enum Status { ... }
>
> private Integer id;
>
> @Enumerated
> private Status status;
> }
>
> Domain classes:
>
> @Inheritance(strategy = InheritanceType.SINGLE_TABLE)
> @Entity
> public class Device {
> ...
> @Embedded
> @AttributeOverrides({
> @AttributeOverride(name="status",
> column=@Column(name="jbackup_status")),
> @AttributeOverride(name="id", column=@Column(name="jbackup_id"))
> })
> protected RegistrationStatus jbackupStatus = RegistrationStatus.UNKNOWN;
> ...
> }
>
> @Entity
> public class Linux extends Device {
> ...
> @Embedded
> @AttributeOverrides({
> @AttributeOverride(name="status",
> column=@Column(name="puppet_status")),
> @AttributeOverride(name="id", column=@Column(name="puppet_id"))
> })
> private RegistrationStatus puppetStatus = RegistrationStatus.UNKNOWN;
>
> @Embedded
> @AttributeOverrides({
> @AttributeOverride(name="status",
> column=@Column(name="spacewalk_status")),
> @AttributeOverride(name="id", column=@Column(name="spacewalk_id"))
> })
> private RegistrationStatus spacewalkStatus = RegistrationStatus.UNKNOWN;
> ...
> }
>
> Sometimes, mapping gets mixed up or something and with em.merge(Linux),
> I'm getting:
>
>>>Duplicate column name "SPACEWALK_ID"; SQL statement:
>>>UPDATE device SET spacewalk_id = ?, spacewalk_status = ?, spacewalk_id =
?, spacewalk_status = ?, spacewalk_id = ?, spacewalk_status = ? WHERE
(device_id = ?) [42121-158]
>
> I cannot repruduce it in simple tests with either EntityManager or my
> Service classes, but it fails quite reliably in simple ZK web application.
>
> Do you have any idea what could have gone wrong? Last @Embedded mapping
> somehow overrides previous two, but why?
>
> Regards,
> Pavel Arnost
>
-----
http://wiki.eclipse.org/User:James.sutherland.oracle.com James Sutherland
http://www.eclipse.org/eclipselink/
EclipseLink , http://www.oracle.com/technology/products/ias/toplink/
TopLink
Wiki: http://wiki.eclipse.org/EclipseLink EclipseLink ,
http://wiki.oracle.com/page/TopLink TopLink
Forums: http://forums.oracle.com/forums/forum.jspa?forumID=48 TopLink ,
http://www.nabble.com/EclipseLink-f26430.html EclipseLink
Book: http://en.wikibooks.org/wiki/Java_Persistence Java Persistence
Blog: http://java-persistence-performance.blogspot.com/ Java Persistence
Performance
--
View this message in context: http://old.nabble.com/Duplicate-column-name-with-%40Embedded-and-%40AttributeOverrides-tp32370401p32381422.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.