openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "howard kelsey (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (OPENJPA-2343) Version field of related entity returns null when explicitly projected in SELECT clause
Date Tue, 05 Mar 2013 11:29:12 GMT

     [ https://issues.apache.org/jira/browse/OPENJPA-2343?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

howard kelsey updated OPENJPA-2343:
-----------------------------------

    Attachment: OPENJPA-2343-2.2.1.x.patch
    
> Version field of related entity returns null when explicitly projected in SELECT clause
> ---------------------------------------------------------------------------------------
>
>                 Key: OPENJPA-2343
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-2343
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: query
>    Affects Versions: 2.2.1
>            Reporter: howard kelsey
>         Attachments: OPENJPA-2343-2.2.1.x.patch
>
>
> With these entities: 
> @Entity
> public class Foo {
>     private int id;
>     private int version;
>     @Id
> 	public int getId() {
> 		return id;
> 	}
> 	public void setId(int id) {
> 		this.id = id;
> 	}
> 	public void setVersion(int version) {
> 		this.version = version;
> 	}	
> 	@Version
> 	public int getVersion() {
> 		return this.version;
> 	}
> }
> @Entity
> public class Bar{
> 	private int id;
> 	private Foo foo;
>     @Id
> 	public int getId() {
> 		return id;
> 	}
> 	public void setId(int id) {
> 		this.id = id;
> 	}
>     public void setFoo(Foo foo) {
>         this.foo = foo;
>     }
>     @ManyToOne
>     public Foo getFoo() {
>         return foo;
>     }
> }
> Insert a record for each associating foo with bar.
> Foo foo = new Foo();
> em.getTransaction().begin(); 
> em.persist(foo); 
> Bar bar = new Bar();
> bar.setFoo(foo);
> em.persist(bar);
> em.getTransaction().commit(); 
> em.close(); 
> queries 
> select bar.id as id, foo as foo from Bar bar join bar.foo foo
> The version field is available via foo.getVersion()
> select bar.id as id, foo.version as version from Bar bar join bar.foo foo
> version is always null.
> By enabling the jdbc debug I can see that the actual SQL being run is correct but the
value is just not hydrated.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Mime
View raw message