You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@openjpa.apache.org by Jan Kotek <op...@gmail.com> on 2008/04/04 17:43:53 UTC

Table per class problem

Hello,
It seems there is bug in table-per-class inheritance. I have this herarchy:

@Inheritance(strategy=InheritanceType.SINGLE_TABLE)
class Car1 {
  int maxSpeed
}

@Inheritance(strategy=InheritanceType.SINGLE_TABLE)
class Car2 {..} extends Car1

@Inheritance(strategy=InheritanceType.TABLE_PER_CLASS)
class Car3{..} extends Car2

Car1 and Car2 are stored in the same table, Car3 is in separated table.

I can run queries:
SELECT c FROM Car1 c3 (returns even Car3 instances)

And also query with condition
SELECT c3 FROM Car3 c3 WHERE c3.maxSpeed > 300

But query on root class  fails with an SQL error exception (Derby
database). OpenJPA generated SQL query with __empty FROM part__, table
name is simply missing.

JPQL query:
SELECT c FROM Car1 c WHERE c.maxSpeed > 300

I traced this problem, SQL query for first table (Car1) was executed
properly, OpenJPA failed on second query from table Car3.

Have someone alse discovered this bug, where should I put it?

Regards,
Jan Kotek

Re: Table per class problem

Posted by Patrick Linskey <pl...@gmail.com>.
Hi,

Sounds like it should be filed as a JIRA issue in the SQL category.

Meanwhile, technically I don't think that your case is covered in the
JPA1 spec. I seem to remember some limitations around mixed-mode
inheritance strategies.

-Patrick

On 4/4/08, Jan Kotek <op...@gmail.com> wrote:
> Hello,
> It seems there is bug in table-per-class inheritance. I have this herarchy:
>
> @Inheritance(strategy=InheritanceType.SINGLE_TABLE)
> class Car1 {
>   int maxSpeed
> }
>
> @Inheritance(strategy=InheritanceType.SINGLE_TABLE)
> class Car2 {..} extends Car1
>
> @Inheritance(strategy=InheritanceType.TABLE_PER_CLASS)
> class Car3{..} extends Car2
>
> Car1 and Car2 are stored in the same table, Car3 is in separated table.
>
> I can run queries:
> SELECT c FROM Car1 c3 (returns even Car3 instances)
>
> And also query with condition
> SELECT c3 FROM Car3 c3 WHERE c3.maxSpeed > 300
>
> But query on root class  fails with an SQL error exception (Derby
> database). OpenJPA generated SQL query with __empty FROM part__, table
> name is simply missing.
>
> JPQL query:
> SELECT c FROM Car1 c WHERE c.maxSpeed > 300
>
> I traced this problem, SQL query for first table (Car1) was executed
> properly, OpenJPA failed on second query from table Car3.
>
> Have someone alse discovered this bug, where should I put it?
>
> Regards,
> Jan Kotek
>


-- 
Patrick Linskey
202 669 5907