[ajug-members] JPA question

Burr Sutter burr.sutter at jboss.com
Tue Nov 21 02:23:10 EST 2006


Typically Map and List are targeting other tables in the database.

What should a list of strings map to?  Most databases don't have array
support the last time I checked.




-----Original Message-----
From: ajug-members-bounces at ajug.org
[mailto:ajug-members-bounces at ajug.org] On Behalf Of J. Talafous
Sent: Monday, November 20, 2006 3:41 PM
To: General AJUG membership forum (100-200 messages/month)
Subject: [ajug-members] JPA question

I'm using Java Persistence API to avoid learning advanced SQL and
doing any db design.  So far it's working pretty well with Hibernate
as the provider, but Toplink is working too, (but doesn't do per-table
@Inheritance).  For example, one of the fields in one of my classes:

@ManyToMany
Map<MyObject,AnotherObject> myMap = new
HashMap<MyObject,AnotherObject>();

persists nicely, no problem.

BUT... anything I try to persist the following, FAILS:

Map<String,String> myMap = new HashMap<String,String>();

or this:

List<String> myList = new ArrayList<String>()

Both JPA providers are claiming that they don't see String.java as an
entity class in persistence.xml, and since I don't have the code, I
can't put it there.

I could wrap String in another class, but this seems like not a good
idea, because it seems JPA should be able to handle this.  For
example:

String[] myList = new String[3]();

gets persisted! Of course, all the @Basic String fields get persisted,
so why is JPA having a problem with Strings inside a List or Map?
it's so simple... I must be missing something here.  Any ideas?

Thanks!
_______________________________________________
ajug-members mailing list
ajug-members at ajug.org
http://www.ajug.org/mailman/listinfo/ajug-members




More information about the ajug-members mailing list