Using Observable Lists within entity classes? [message #516797] |
Thu, 25 February 2010 03:49  |
Eclipse User |
|
|
|
I have 2 entity classes which both have collections of each other's type in many-many config. something like the code below:-
@entity
@Table(name = "A")
...
@JoinTable(name = "JOIN_TBL",
joinColumns = @JoinColumn(name = "COL_ID"),
inverseJoinColumns = @JoinColumn(name = "J_COL_ID"))
private Collection<B> BCollection;
...
and then
@entity
@Table(name = "B")
...
@ManyToMany(mappedBy = "sembookingsCollection", cascade=CascadeType.ALL,fetch=FetchType.EAGER)
private Collection<A> ACollection;
..
Within the application I bind ACollection to a JTable...
org.jdesktop.beansbinding.ELProperty eLProperty = org.jdesktop.beansbinding.ELProperty.create("${selectedElement.ACollection}");
org.jdesktop.swingbinding.JTableBinding jTableBinding = org.jdesktop.swingbinding.SwingBindings.createJTableBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, masterTable, eLProperty, detailTable);
The above is all pretty standard stuff and my JTable doesn't get updated after changes to ACollection.
I can see I an Observable wrapper around the ACollection might do the trick but Observable Lists are not supported in the JPA spec. for entity classes.
Setting fetchType to EAGER doesn't solve the problem (and perhaps it shouldn't).
Apart from observable lists I can't see how to update a list in real time. Does anyone have a solution to this issue?
many thanks,
|
|
|
|
Re: Using Observable Lists within entity classes? [message #517010 is a reply to message #516987] |
Thu, 25 February 2010 12:38  |
Eclipse User |
|
|
|
Hello Chris,
I sorted the problem.
Basically the application is stand alone using an application managed entity manager so I pass it around as a class parameter. (I wonder if there's a better way of doing this?)
However, in this particular class I declared a new entityManager (joys of using an IDE) and used that instead of using the manager passed in. I suspect this meant a new persistance context was created which masked the main context.
Now everything is working fine.
Depending how code is structured I gusess it's always possible to avoid the need for an observable list within an entity class declaration.
Thanks for replying,
Olu.
[Updated on: Thu, 25 February 2010 12:39] by Moderator
|
|
|
Powered by
FUDForum. Page generated in 0.08865 seconds