Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Map<Enum, Entity> table creation works (3 columns), query is wrong (2 values)
icon5.gif  Map<Enum, Entity> table creation works (3 columns), query is wrong (2 values) [message #897496] Tue, 24 July 2012 09:59 Go to next message
Simon Ascender is currently offline Simon AscenderFriend
Messages: 1
Registered: July 2012
Junior Member
Hi,

i migrate from hibernate, and need a little bit help...
@Entity
UserIdentity
{
 @OneToMany
 @MapKeyColumn(length = 8)
 @MapKeyEnumerated(EnumType.STRING)
 public Map<AddressType, PostalAddress> getPostalAddress()
}

@Entity
public class PostalAddress implements Serializable {...}

public enum AddressType { HOME, WORK, OTHER... }

Eclipselink create the table correct, with 3 columns:
[UserIdentity_ID | PostalAddress_ID | PostalAddress_KEY]

but wrong querys:
INSERT INTO USERIDENTITY_POSTALADDRESS (UserIdentity_ID, PostalAddress_ID) VALUES (?, ?)

i try and search several hours, @MapKeyClass, @MapKeyConvert and many more, but without success...
now i am very frustrated, this looks for me more than a eclipselink bug? i hope someone can help...

in use: eclipselink 2.3.3, persistence 2.0.3 and org.eclipse.persistence.jpa.PersistenceProvider


p.s. Map<Enum, String> works great:
@ElementCollection
@MapKeyColumn(length = 8)
@MapKeyEnumerated(EnumType.STRING)
public Map<PhoneType, String> getPhoneNumber()


Re: Map<Enum, Entity> table creation works (3 columns), query is wrong (2 values) [message #899664 is a reply to message #897496] Wed, 01 August 2012 17:44 Go to previous message
James Sutherland is currently offline James SutherlandFriend
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

I could not find any test for this case (OneToMany using JoinTable and MapKeyColumn), so it may be a bug.

Please log a bug for this and vote for it.

As a workaround your could map the join table to an object,

see,
http://en.wikibooks.org/wiki/Java_Persistence/ManyToMany#Mapping_a_Join_Table_with_Additional_Columns


James : Wiki : Book : Blog : Twitter
Previous Topic:Postgresql NULLS FIRST Order by
Next Topic:The parameter name in the query's selection criteria does not match any parameter name defi
Goto Forum:
  


Current Time: Fri Apr 26 11:03:24 GMT 2024

Powered by FUDForum. Page generated in 0.03037 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top