[ 
https://issues.apache.org/jira/browse/OPENJPA-2651?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15422306#comment-15422306
 ] 

Francesco Chicchiriccò commented on OPENJPA-2651:
-------------------------------------------------

{quote}
I don't know, maybe no one is using 2.3.x these days?
{quote}

The Syncope maintenance branch 1_2_X [1] is doing that, here's why I've gladly 
applied your patch :-)

{quote}
For example, the testing I was doing was on 2.2.x, and therefore I was using 
the latest code, which is 2.2.3. If I was on 1.2.x I'd be using 1.2.4, and as 
such list it. Continuing with 1.2.4, I'd take the testing and fix forward to 
2.0.x, 2.1.x, 2.2.x, and trunk; where applicable. As such, I'd list those as 
the affected versions.
{quote}

You've been actually testing on (and providing patches for) 2.2.3-SNAPSHOT and 
2.4.2-SNAPSHOT, hence the fix will be delivered when we'll release 2.2.3 and 
2.4.2: here's why the fix-for-version is important to correctly include 2.2.3 
and 2.4.2, to get through to appropriate release notes.

Thanks again for your work.

[1] 
https://git-wip-us.apache.org/repos/asf?p=syncope.git;a=shortlog;h=refs/heads/1_2_X

> IDs of entities are incorrectly assigned when @SqlResultSetMapping is used 
> with inheritance and a ManyToOne relationship.
> -------------------------------------------------------------------------------------------------------------------------
>
>                 Key: OPENJPA-2651
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-2651
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: sql
>    Affects Versions: 2.2.2, 2.3.0, 2.4.1
>            Reporter: Heath Thomann
>            Assignee: Heath Thomann
>            Priority: Critical
>             Fix For: 2.2.3, 2.3.1, 2.4.2
>
>         Attachments: OPENJPA-2651-2.2.x.patch, SqlResultSetMappingIssue.zip
>
>
> I have discovered an issue with using @SqlResultSetMapping when inheritance 
> and ManyToOne relationships are used.  To explain the issue, take this entity 
> and @SqlResultSetMapping:
> @Entity
> @SqlResultSetMapping(name = "MyResMap", entities = { 
> @EntityResult(entityClass = CrtRequisicaoChequePersEntity.class, fields = {
>     @FieldResult(name = "crtOperacaoByOperacaoRecepcaoServCent.id", column = 
> "opRecepcaoServCentraisId"),
>     @FieldResult(name = "crtOperacaoByOperacaoRecepcaoServCent.dataHora", 
> column = "opRecepcaoServCentraisDataHora") 
>     }) 
> })
> public class CrtRequisicaoChequePersEntity extends CrtRequisicaoEntity {
> .......
>     @ManyToOne
>     @javax.persistence.JoinColumn(name = "OPERACAO_RECEPCAO_SERV_CENT", 
> referencedColumnName = "ID")
>     private CrtOperacaoEntity crtOperacaoByOperacaoRecepcaoServCent;
> As you can see, this entity extends 'CrtRequisicaoEntity' and has a ManyToOne 
> relationship to 'CrtOperacaoEntity', with name 
> 'crtOperacaoByOperacaoRecepcaoServCent'.  As you can see, the @FieldResult in 
> the @SqlResultSetMapping references the fields in 'CrtOperacaoEntity'.   
> These two entities are defined as follows:
> @Entity
> @Inheritance(strategy = InheritanceType.JOINED)
> public class CrtRequisicaoEntity {
> .....
>     @Id
>     private long id;
> .....
> @Entity
> public class CrtOperacaoEntity implements Serializable {
> .....
>     @Id
>     private long id;
>     @Basic
>     private Timestamp dataHora;
> With these entities, take an SQL select which uses an AS (the entire SQL is 
> to long to add here, see provided recreate/test attached):
> String sqlCust = "SELECT t0.ID" +
> .........
> ",t2.DATA_HORA as opRecepcaoServCentraisDataHora" +
> ",t2.ID as opRecepcaoServCentraisId" +
> ....
> "FROM CrtRequisicaoChequePersEntity t0"
> ....                
> "INNER JOIN CrtOperacaoEntity t2"
> ....
> With this SQL, the two IDs will be populated with the ID from 
> CrtRequisicaoChequePersEntity, rather than the ID corresponding to each 
> entity.
> Thanks,
> Heath



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to