Joachim,
I have never attmepted to do an instanceof with the inheritance type of a single table per
hierarchy. Prehaps you should investigate some other strategies, namely table per
subclass as i think this will provide you with the functionality you would like, like so:
| //create query
| Query tmpQuery = mEntityManager.createQuery("FROM Tag t");
|
| //get query result
| ArrayList<Tag> queryResult =
(ArrayList<Tag>)tmpQuery.getResultList();
|
| //get iterator
| Iterator it = testList.iterator();
|
| //loop
| while (it.hasNext()) {
| Tag element = (Tag) it.next();
|
| if(element instanceof PlaceMark) {
| //DO STUFF :-)
| }
| }
|
In your top level parent class you just need to annotate like so:
@Inheritance(strategy = InheritanceType.JOINED)
and i just have a getter and setter for the id in this parent class, and not in the
sub-classes(children). All you should need to do in the children classes is just extend
the parent class.
To persist, just create and persist a child object and it automatically create and
persists the parent objet with the correct attributes.
Cheers,
Andy
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3991643#...
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&a...