On 6/03/11 9:03 PM, Bruno René Santos wrote:
I have an object structure with a Child dataobject which inherits from a Parent 
which is linked to a db_entity. I am trying to use the Parent on a GUI and the 
Child on another GUI. The Child overrides some methods from the Parent (but the 
db table is the same) and so is mandatory that on each GUI their respective 
searches yeld Child objects or Parent objects. On the GUI that uses the Child 
everything goes according plan, the performQueries return lists of Children. 
But on the Parent GUI I call

context.performQuery(new SelectQuery(Parent.class))

but the method returns also a list of Children, which are incompatible with the 
parent GUI. Is there any way that this query returns Parents instead of 
Children? I was trying these inheritance so that i could reuse all db fields 
and relationships from the parent on the child.

What does the discriminator column say about these objects? Are they actually 
Child entities in the database or Parent? They can't be both at the same time.

This isn't like plain-old Java inheritance where you can just cast from one to 
the other as needed. If you could, what would happen if you queried for a list 
of Child objects, casting them as Parents, changed some Parent attribute and 
committed the context? Would they now become Parents in the database?

Ari


--
-------------------------->
Aristedes Maniatis
GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A

Reply via email to