Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Howto map a map?
Howto map a map? [message #666821] Fri, 22 April 2011 20:07 Go to next message
Martin Taal is currently offline Martin Taal
Messages: 5332
Registered: July 2009
Senior Member
Hi,
I have a field/member which has this type;
public Map<String, Writer> getWriters() {
return writers;
}

the key of the map is not a property of the writer, so a join table is needed. How do I map this using an orm xml file?

I tried this:
<orm:one-to-many name="writers">
<orm:map-key-class class="java.lang.String"/>
<orm:join-table/>
<orm:cascade>
<orm:cascade-all/>
</orm:cascade>
</orm:one-to-many>

But then I get this:
The field [BOOK.WRITERS_KEY] in this expression has an invalid table in this context.


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Re: Howto map a map? [message #666853 is a reply to message #666821] Sat, 23 April 2011 11:01 Go to previous messageGo to next message
Martin Taal is currently offline Martin Taal
Messages: 5332
Registered: July 2009
Senior Member
Hmm this seems to work fine:
<orm:one-to-many name="writers">
<orm:map-key-class class="java.lang.String"/>
<orm:map-key-column table="_1303556303411"/>
<orm:join-table name="_1303556303411"/>
<orm:cascade>
<orm:cascade-all/>
</orm:cascade>
</orm:one-to-many>

So I explicitly set the table of the map key column, if I don't set the tablename in the map-key-column/join-table then
EclipseLink throws an exception (the same as in the previous post). But I prefer EclipseLink to generate the table name,
is there a mapping I can use without specifying an explicit table name?

gr. Martin

On 04/22/2011 10:07 PM, Martin Taal wrote:
> Hi,
> I have a field/member which has this type;
> public Map<String, Writer> getWriters() {
> return writers;
> }
>
> the key of the map is not a property of the writer, so a join table is needed. How do I map this using an orm xml file?
>
> I tried this:
> <orm:one-to-many name="writers">
> <orm:map-key-class class="java.lang.String"/>
> <orm:join-table/>
> <orm:cascade>
> <orm:cascade-all/>
> </orm:cascade>
> </orm:one-to-many>
>
> But then I get this:
> The field [BOOK.WRITERS_KEY] in this expression has an invalid table in this context.
>
>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Re: Howto map a map? [message #667231 is a reply to message #666853] Wed, 27 April 2011 14:44 Go to previous message
James Sutherland is currently offline James Sutherland
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

The table should be defaulted if not specified, please log a bug.
As a workaround just set the table to what would be generated.


James : Wiki : Book : Blog : Twitter
Previous Topic:OutOfMemory ScrollableCursor
Next Topic:Apparent interface violation in CriteriaBuilderImpl
Goto Forum:
  


Current Time: Fri Sep 19 01:55:13 GMT 2014

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

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