openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nibbler <Michael.Schn...@VerizonWireless.com>
Subject Re: Help - Single table inheritance not working with one-to-many collection
Date Mon, 08 Dec 2008 23:53:24 GMT

I think you're actually having the same results as me, but your table values
are different (specifically the containing_obj_id column).  My trace looks
like yours, i.e. it doesn't have the discriminator column in the sql.

1271  test  TRACE  [main] openjpa.jdbc.SQL - <t 3916302, conn 24124380>
executing prepstmnt 14008569 SELECT t0.id_column, t0.discriminator,
t0.containing_obj_id, t0.column_a, t0.column_b FROM test_table t0 WHERE
t0.containing_obj_id = ? [params=(long) 1]

Your containing_obj_id column has null values for type 'D' discriminators, I
think that's why you're getting the 3 TestChild1s back.  If I null the 'D'
rows, I also get 3. This Query:

Query a = em.createQuery("select tc1 from TestChild tc1 where
tc1.containingObjId=1");
List<TestChild1> list = (List<TestChild1>)query.getResultList();

will result in the correct sql:
1444  test  TRACE  [main] openjpa.jdbc.SQL - <t 3916302, conn 33187868>
executing prepstmnt 22975191 SELECT t0.id_column, t0.discriminator,
t0.containing_obj_id, t0.column_a, t0.column_b FROM test_table t0 WHERE
(t0.containing_obj_id = ?) AND t0.discriminator = ? [params=(long) 1,
(String) S]

The discriminator column is being used here.  I think if you set the
containing_obj_id column for the other rows, you'll see the problem I am
seeing.  Is this a bug in openjpa or am I misusing it?

I am using openjpa-1.0.2.jar, with the Enhancer.

Thanks again,
-Mike



Fay Wang wrote:
> 
> Hi Mike,
>    I do have the discriminator column. I have the following columns in my
> test_table:
> 
> Column name
> ------------------
> ID_COLUMN
> COLUMN_A
> SITE_ID
> DISCRIMINATOR
> COLUMN_B
> CONTAINING_OBJ_ID
> 
> The sql "select id_column, CONTAINING_OBJ_ID, discriminator from
> test_table" generates the following result:
> 
> ID_COLUMN            CONTAINING_OBJ_ID DISCRIMINATOR
> -------------------- ----------------- -------------------------------
>                    1                 1 S
>                    3                 1 S
>                    4                 - D
>                    2                 1 S
>                    5                 - D
> 
> To get the trace, you can put 
> 	<property name="openjpa.Log" value="DefaultLevel=TRACE" />
> in your persistence.xml. 
> 
> Regards,
> Fay
> 
>       
> 
> 

-- 
View this message in context: http://n2.nabble.com/Help---Single-table-inheritance-not-working-with-one-to-many-collection-tp1620948p1631574.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.


Mime
View raw message