Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] Null @Id again after query execution

Hi Laird,

One way to narrow this down is to write a junit test case and submit
it as a bug. While playing with the test case, you may find a
workaround that gives you some breathing space before the bug (if it
is one) is fixed, or to find a correct solution. While mirating to the
latest Eclipse version, I found 3 issues with my current software, 2
of them were EL bugs and 1 was my own.

Feel free to examine the test cases in the following issues:

SQL Generation overrides NOT, AND Operator Precedence
https://bugs.eclipse.org/bugs/show_bug.cgi?id=387165
This is interesting because it generates incorrect SQL since 2.4

NamedQuery with null Parameter fails at Runtime with Postgresql
https://bugs.eclipse.org/bugs/show_bug.cgi?id=387545

Simple JPQL with guarded null Parameter fails with Postgresql
https://bugs.eclipse.org/bugs/show_bug.cgi?id=377586
This is now fixed but it has a Maven testcase. I haven't seen EL 2.4
in the maven repository yet.

Otherwise you might find that your issue is already recorded at:

https://bugs.eclipse.org/bugs/query.cgi

Kind Regards,

Bernard





On Fri, 31 Aug 2012 15:42:08 -0700, you wrote:

>I have a (weird) inheritance structure like this:
>
>@Entity(name = "Party")
>@DiscriminatorColumn(name = "kind", discriminatorType =
>DiscriminatorType.STRING, length = 30)
>@DiscriminatorValue("Party")
>@Inheritance(strategy = InheritanceType.JOINED)
>@Table(name = "Party")
>// other stuff
>public abstract class PartyEntity ...
>  @Id
>  @Column(name = "id", updatable = false)
>  Long id;
>
>@MappedSuperclass
>public abstract PersonMappedSuperclass extends PartyEntity...
>  // various basic mappings here; no further @Id annotations
>
>@Entity(name = "Person")
>@DiscriminatorValue("Person")
>@Table(name = "Person")
>public class PersonEntity extends PersonMappedSuperclass...
>  // more mappings; no @Id annotations
>  // one to many with names, etc.
>
>When I retrieve such an object via a particular named query, I can see in
>the debugger that his id property is null.  This never happened in the
>version of EclipseLink that shipped as part of GlassFish 3.1.
>
>This should not be the case, correct?  Have I misunderstood what is and is
>not permitted in an inheritance hierarchy?
>
>My named query in all its glory looks like this--it finds a Person based on
>values for certain names the person has:
>
>SELECT p FROM Person p JOIN p.names n WHERE (n.nameType.code =
>'legalFirstName' OR n.nameType.code = 'legalLastName') AND n.value LIKE
>:text
>
>The resulting SQL from this is (rather suspiciously; note in particular the
>double "id" column retrieval--i.e. "id" is not present only in the WHERE
>clause but in the SELECT clause as well, with no way to distinguish between
>them):
>
>SELECT
>t2.id,
>t2.kind,
>[snip]
>t2.version,
>t3.id,
>[snip; other t3 columns]
>FROM Person t3, Party t2, Name t1, NameType t0
>WHERE
>(
>   (
>      (((t0.code = 'legalFirstName') OR (t0.code = 'legalLastName')) AND
>t1.nameValue LIKE 'Lair%')
>      AND ((t3.id = t2.id) AND (t2.kind = 'Person'))
>   )
>   AND ((t1.owningPartyID = t2.id) AND (t0.id = t1.nameTypeID))
>)
>
>The resulting Person entity has a null id property.
>
>I'm really not sure where to go next with this.
>
>Best,
>Laird



Back to the top