-
1. Re: Using entities with collections?
fheldt Jul 31, 2006 2:56 AM (in response to sbalmos)Here's what i did: The entity bean is field mapped and the getters/setters convert between Collection and Array.
A sample:public class MyEntityBean implements java.io.Serializable { @Id @Column(name="id") private int id; ... @OneToMany(mappedBy = "abc") private Set<ColumnHeader> colHeaders; ... public ColumnHeader[] getColumns() { return this.colHeaders.toArray(new ColumnHeader[ this.colHeaders.size() ]); } public void setColumns(ColumnHeader[] colHeaders) { this.colHeaders.clear(); for (int i = 0; i < colHeaders.length; i++) { this.colHeaders.add(colHeaders[ i ]); } } }
-
2. Re: Using entities with collections?
sbalmos Jul 31, 2006 9:17 AM (in response to sbalmos)Groan... Nothing like rewriting all those getters/setters, the annotations, etc. :) I'm guessing there's no real difference in using property vs field annotations.
What's worse is that some of my entities use Map-type collections, which there is no support at all for (I thought SOAP had some key-value type primitive???). I have no idea how I am going to fix that. I thought about writing XmlAdapters, like in http://weblogs.java.net/blog/kohsuke/archive/2005/04/xmladapter_in_j.html , but I just tried that. The WSDL generator doesn't pick up on the adapter, and continues to almost-silently ignore the Map.
Ideas for that one would be even more appreciated. Thanks!
--Scott