Re: Can't obtain Primary Key value by JPQL

2010-11-08 Thread Rick Curtis
Thanks for all of the responses! I finally got this setup and it looks like
the eclipse build time enhancer has some issues with it.

I'll post something to dev to see if we can get this fixed up.

Thanks,
Rick

On Mon, Nov 8, 2010 at 9:27 AM, Alex, Huang  wrote:

> It's my pleasure.
>
> Thanks
> Alex,Huang
> - Original Message -
> From: "Rick Curtis" 
> To: 
> Sent: Monday, November 08, 2010 10:17 PM
> Subject: Re: Can't obtain Primary Key value by JPQL
>
>
> > Hopefully I'll find some time this afternoon to get that setup. In the
> > mean
> > time, could I get you to upload your Entity which was enhanced by the
> > plugin?
> >
> > Thanks,
> > Rick
> >
> > On Sun, Nov 7, 2010 at 11:38 AM, Alex, Huang 
> wrote:
> >
> >> Rick,
> >>
> >> I installed OpenJPA eclipse tooling on Eclipse 3.6... I think it's the
> >> reason.
> >>
> >> my environment:
> >> Eclipse:
> >> Version: 3.6.0.v20100602-9gF78GpqFt6trOGhL60z0oEx3fz-JKNwxPY
> >> Build id: I20100608-0911
> >> Then I installed plug-in from
> >> http://openjpa.apache.org/openjpaeclipseinstallation.html and I used
> the
> >> tool for enhancement.
> >>
> >> Best regards,
> >> Alex,Huang
> >>
> >> - Original Message -
> >> From: "Rick Curtis" 
> >> To: 
> >> Sent: Saturday, November 06, 2010 2:43 AM
> >> Subject: Re: Can't obtain Primary Key value by JPQL
> >>
> >>
> >> > Can you point me to how you were enhancing your Entities... I'd like
> to
> >> > get
> >> > to the bottom of this one.
> >> >
> >> > Thanks,
> >> > Rick
> >> >
> >> > On Fri, Nov 5, 2010 at 12:18 AM, Alex, Huang 
> >> wrote:
> >> >
> >> >> Hi Rick,
> >> >>
> >> >> I got the reason. I always enhance entities by Eclipse plug-in.
>  After
> >> >> got
> >> >> your clue, I enhanced entities again by using command. And the
> problem
> >> >> disappeared.
> >> >>
> >> >> Really thank you for all the help.
> >> >> Alex, Huang
> >> >>
> >> >> - Original Message -
> >> >> From: "Rick Curtis" 
> >> >> To: 
> >> >> Sent: Friday, November 05, 2010 1:20 AM
> >> >> Subject: Re: Can't obtain Primary Key value by JPQL
> >> >>
> >> >>
> >> >> > How are you enhancing your Entities? If you are using build time,
> >> >> > can
> >> >> > you
> >> >> > post the enhanced .class file?
> >> >> >
> >> >> > Thanks,
> >> >> > Rick
> >> >> >
> >> >> > On Wed, Nov 3, 2010 at 8:32 PM, Alex, Huang 
> >> >> wrote:
> >> >> >
> >> >> >> Hi Rick,
> >> >> >>
> >> >> >> >How did you get the data into your DB?
> >> >> >> I  insert data at mysql prompt.
> >> >> >> 
> >> >> >> mysql> INSERT INTO t_user(name,age) VALUES ('John', 26);
> >> >> >> Query OK, 1 row affected (0.03 sec)
> >> >> >> 
> >> >> >>
> >> >> >> Now,db's data like below,
> >> >> >> 
> >> >> >> mysql> select * from t_user;
> >> >> >> +-++-+
> >> >> >> | uid | name   | age |
> >> >> >> +-++-+
> >> >> >> |   1 | Huang  |  26 |
> >> >> >> |   2 | Alex   |  28 |
> >> >> >> |   3 | tester |  22 |
> >> >> >> |   4 | John   |  26 |
> >> >> >> +-++-+
> >> >> >> 4 rows in set (0.00 sec)
> >> >> >> 
> >> >> >>
> >> >> >> >What happens if you call em.find(TUser.class, [known_id]) ?
> >> >> >>
> >> >> >> I run the following case, and it completed successful.
> >> >> >> ===

Re: Can't obtain Primary Key value by JPQL

2010-11-08 Thread Alex, Huang
It's my pleasure.

Thanks
Alex,Huang
- Original Message - 
From: "Rick Curtis" 
To: 
Sent: Monday, November 08, 2010 10:17 PM
Subject: Re: Can't obtain Primary Key value by JPQL


> Hopefully I'll find some time this afternoon to get that setup. In the 
> mean
> time, could I get you to upload your Entity which was enhanced by the
> plugin?
>
> Thanks,
> Rick
>
> On Sun, Nov 7, 2010 at 11:38 AM, Alex, Huang  wrote:
>
>> Rick,
>>
>> I installed OpenJPA eclipse tooling on Eclipse 3.6... I think it's the
>> reason.
>>
>> my environment:
>> Eclipse:
>> Version: 3.6.0.v20100602-9gF78GpqFt6trOGhL60z0oEx3fz-JKNwxPY
>> Build id: I20100608-0911
>> Then I installed plug-in from
>> http://openjpa.apache.org/openjpaeclipseinstallation.html and I used the
>> tool for enhancement.
>>
>> Best regards,
>> Alex,Huang
>>
>> - Original Message -
>> From: "Rick Curtis" 
>> To: 
>> Sent: Saturday, November 06, 2010 2:43 AM
>> Subject: Re: Can't obtain Primary Key value by JPQL
>>
>>
>> > Can you point me to how you were enhancing your Entities... I'd like to
>> > get
>> > to the bottom of this one.
>> >
>> > Thanks,
>> > Rick
>> >
>> > On Fri, Nov 5, 2010 at 12:18 AM, Alex, Huang 
>> wrote:
>> >
>> >> Hi Rick,
>> >>
>> >> I got the reason. I always enhance entities by Eclipse plug-in.  After
>> >> got
>> >> your clue, I enhanced entities again by using command. And the problem
>> >> disappeared.
>> >>
>> >> Really thank you for all the help.
>> >> Alex, Huang
>> >>
>> >> - Original Message -
>> >> From: "Rick Curtis" 
>> >> To: 
>> >> Sent: Friday, November 05, 2010 1:20 AM
>> >> Subject: Re: Can't obtain Primary Key value by JPQL
>> >>
>> >>
>> >> > How are you enhancing your Entities? If you are using build time, 
>> >> > can
>> >> > you
>> >> > post the enhanced .class file?
>> >> >
>> >> > Thanks,
>> >> > Rick
>> >> >
>> >> > On Wed, Nov 3, 2010 at 8:32 PM, Alex, Huang 
>> >> wrote:
>> >> >
>> >> >> Hi Rick,
>> >> >>
>> >> >> >How did you get the data into your DB?
>> >> >> I  insert data at mysql prompt.
>> >> >> 
>> >> >> mysql> INSERT INTO t_user(name,age) VALUES ('John', 26);
>> >> >> Query OK, 1 row affected (0.03 sec)
>> >> >> 
>> >> >>
>> >> >> Now,db's data like below,
>> >> >> 
>> >> >> mysql> select * from t_user;
>> >> >> +-++-+
>> >> >> | uid | name   | age |
>> >> >> +-++-+
>> >> >> |   1 | Huang  |  26 |
>> >> >> |   2 | Alex   |  28 |
>> >> >> |   3 | tester |  22 |
>> >> >> |   4 | John   |  26 |
>> >> >> +-++-+
>> >> >> 4 rows in set (0.00 sec)
>> >> >> 
>> >> >>
>> >> >> >What happens if you call em.find(TUser.class, [known_id]) ?
>> >> >>
>> >> >> I run the following case, and it completed successful.
>> >> >> 
>> >> >>  public void testFind(){
>> >> >>  EntityManager em = emf.createEntityManager();
>> >> >>  em.getTransaction().begin();
>> >> >>   TUser user  = em.find(TUser.class, 2);
>> >> >>  assertEquals("Alex", user.getName());
>> >> >>  assertEquals(28, user.getAge());
>> >> >>  }
>> >> >> 
>> >> >>
>> >> >> After  I added "assertEquals(2,user.getUid());", 
>> >> >> AssertionFailedError
>> >> >> occured.
>> >> >> 
>> >> >> junit.framework.Asser

Re: Can't obtain Primary Key value by JPQL

2010-11-08 Thread Rick Curtis
Hopefully I'll find some time this afternoon to get that setup. In the mean
time, could I get you to upload your Entity which was enhanced by the
plugin?

Thanks,
Rick

On Sun, Nov 7, 2010 at 11:38 AM, Alex, Huang  wrote:

> Rick,
>
> I installed OpenJPA eclipse tooling on Eclipse 3.6... I think it's the
> reason.
>
> my environment:
> Eclipse:
> Version: 3.6.0.v20100602-9gF78GpqFt6trOGhL60z0oEx3fz-JKNwxPY
> Build id: I20100608-0911
> Then I installed plug-in from
> http://openjpa.apache.org/openjpaeclipseinstallation.html and I used the
> tool for enhancement.
>
> Best regards,
> Alex,Huang
>
> - Original Message -
> From: "Rick Curtis" 
> To: 
> Sent: Saturday, November 06, 2010 2:43 AM
> Subject: Re: Can't obtain Primary Key value by JPQL
>
>
> > Can you point me to how you were enhancing your Entities... I'd like to
> > get
> > to the bottom of this one.
> >
> > Thanks,
> > Rick
> >
> > On Fri, Nov 5, 2010 at 12:18 AM, Alex, Huang 
> wrote:
> >
> >> Hi Rick,
> >>
> >> I got the reason. I always enhance entities by Eclipse plug-in.  After
> >> got
> >> your clue, I enhanced entities again by using command. And the problem
> >> disappeared.
> >>
> >> Really thank you for all the help.
> >> Alex, Huang
> >>
> >> - Original Message -
> >> From: "Rick Curtis" 
> >> To: 
> >> Sent: Friday, November 05, 2010 1:20 AM
> >> Subject: Re: Can't obtain Primary Key value by JPQL
> >>
> >>
> >> > How are you enhancing your Entities? If you are using build time, can
> >> > you
> >> > post the enhanced .class file?
> >> >
> >> > Thanks,
> >> > Rick
> >> >
> >> > On Wed, Nov 3, 2010 at 8:32 PM, Alex, Huang 
> >> wrote:
> >> >
> >> >> Hi Rick,
> >> >>
> >> >> >How did you get the data into your DB?
> >> >> I  insert data at mysql prompt.
> >> >> 
> >> >> mysql> INSERT INTO t_user(name,age) VALUES ('John', 26);
> >> >> Query OK, 1 row affected (0.03 sec)
> >> >> 
> >> >>
> >> >> Now,db's data like below,
> >> >> 
> >> >> mysql> select * from t_user;
> >> >> +-++-+
> >> >> | uid | name   | age |
> >> >> +-++-+
> >> >> |   1 | Huang  |  26 |
> >> >> |   2 | Alex   |  28 |
> >> >> |   3 | tester |  22 |
> >> >> |   4 | John   |  26 |
> >> >> +-++-+
> >> >> 4 rows in set (0.00 sec)
> >> >> 
> >> >>
> >> >> >What happens if you call em.find(TUser.class, [known_id]) ?
> >> >>
> >> >> I run the following case, and it completed successful.
> >> >> 
> >> >>  public void testFind(){
> >> >>  EntityManager em = emf.createEntityManager();
> >> >>  em.getTransaction().begin();
> >> >>   TUser user  = em.find(TUser.class, 2);
> >> >>  assertEquals("Alex", user.getName());
> >> >>  assertEquals(28, user.getAge());
> >> >>  }
> >> >> 
> >> >>
> >> >> After  I added "assertEquals(2,user.getUid());", AssertionFailedError
> >> >> occured.
> >> >> 
> >> >> junit.framework.AssertionFailedError: expected:<2> but was:<0>
> >> >> 
> >> >>
> >> >> >Could you try creating some data and persisting it via JPA?
> >> >> OK.I added a method to test case.
> >> >> ==
> >> >>  public void testInsert(){
> >> >>   EntityManager em = emf.createEntityManager();
> >> >>  em.getTransaction().begin();
> >> >>   TUser user = new TUser();
> >> >>  user.setName("Jeason");
> >> >>  user.setAge(27);
> >> >>  em.p

Re: Can't obtain Primary Key value by JPQL

2010-11-07 Thread Alex, Huang
Rick,

I installed OpenJPA eclipse tooling on Eclipse 3.6... I think it's the 
reason.

my environment:
Eclipse:
Version: 3.6.0.v20100602-9gF78GpqFt6trOGhL60z0oEx3fz-JKNwxPY
Build id: I20100608-0911
Then I installed plug-in from 
http://openjpa.apache.org/openjpaeclipseinstallation.html and I used the 
tool for enhancement.

Best regards,
Alex,Huang

- Original Message - 
From: "Rick Curtis" 
To: 
Sent: Saturday, November 06, 2010 2:43 AM
Subject: Re: Can't obtain Primary Key value by JPQL


> Can you point me to how you were enhancing your Entities... I'd like to 
> get
> to the bottom of this one.
>
> Thanks,
> Rick
>
> On Fri, Nov 5, 2010 at 12:18 AM, Alex, Huang  wrote:
>
>> Hi Rick,
>>
>> I got the reason. I always enhance entities by Eclipse plug-in.  After 
>> got
>> your clue, I enhanced entities again by using command. And the problem
>> disappeared.
>>
>> Really thank you for all the help.
>> Alex, Huang
>>
>> ----- Original Message -----
>> From: "Rick Curtis" 
>> To: 
>> Sent: Friday, November 05, 2010 1:20 AM
>> Subject: Re: Can't obtain Primary Key value by JPQL
>>
>>
>> > How are you enhancing your Entities? If you are using build time, can 
>> > you
>> > post the enhanced .class file?
>> >
>> > Thanks,
>> > Rick
>> >
>> > On Wed, Nov 3, 2010 at 8:32 PM, Alex, Huang 
>> wrote:
>> >
>> >> Hi Rick,
>> >>
>> >> >How did you get the data into your DB?
>> >> I  insert data at mysql prompt.
>> >> 
>> >> mysql> INSERT INTO t_user(name,age) VALUES ('John', 26);
>> >> Query OK, 1 row affected (0.03 sec)
>> >> 
>> >>
>> >> Now,db's data like below,
>> >> 
>> >> mysql> select * from t_user;
>> >> +-++-+
>> >> | uid | name   | age |
>> >> +-++-+
>> >> |   1 | Huang  |  26 |
>> >> |   2 | Alex   |  28 |
>> >> |   3 | tester |  22 |
>> >> |   4 | John   |  26 |
>> >> +-++-+
>> >> 4 rows in set (0.00 sec)
>> >> 
>> >>
>> >> >What happens if you call em.find(TUser.class, [known_id]) ?
>> >>
>> >> I run the following case, and it completed successful.
>> >> 
>> >>  public void testFind(){
>> >>  EntityManager em = emf.createEntityManager();
>> >>  em.getTransaction().begin();
>> >>   TUser user  = em.find(TUser.class, 2);
>> >>  assertEquals("Alex", user.getName());
>> >>  assertEquals(28, user.getAge());
>> >>  }
>> >> 
>> >>
>> >> After  I added "assertEquals(2,user.getUid());", AssertionFailedError
>> >> occured.
>> >> 
>> >> junit.framework.AssertionFailedError: expected:<2> but was:<0>
>> >> 
>> >>
>> >> >Could you try creating some data and persisting it via JPA?
>> >> OK.I added a method to test case.
>> >> ==
>> >>  public void testInsert(){
>> >>   EntityManager em = emf.createEntityManager();
>> >>  em.getTransaction().begin();
>> >>   TUser user = new TUser();
>> >>  user.setName("Jeason");
>> >>  user.setAge(27);
>> >>  em.persist(user);
>> >>  em.getTransaction().commit();
>> >>  em.close();
>> >>  }
>> >> ==
>> >>
>> >> I run the test case and it completed successful. At mysql prompt I
>> >> confirmed
>> >> the data has been created.
>> >>
>> >> ==
>> >> mysql> select * from t_user;
>> >> +-++-+
>> >> | uid | name   | age |
>> >> +-++-+
>> >> |   1 | Huang  |  26 |
>> >> |   2 | Alex   |  28 |
>> >> |   3 | tester |  22 |
>> >> |   4 | John   |  26 |
>> >> |   5 | Jeason |  27 |
>> >> +-++-+
>> >> 5 rows in set (0.00 sec)
>> >> ==
>> >>
>> >> Look forward to your advance.
>> >> Alex,Huang
>> >> - Original Message -
>> >> From: "Rick Curtis" 
>> >> To: 
>> >> Sent: Thursday, November 04, 2010 5:29 AM
>> >> Subject: Re: Can't obtain Primary Key value by JPQL
>> >>
>> >>
>> >> > That looks about identical to the test case that I came up with.
>> >> >
>> >> >> Any advice?
>> >> > I'm running low on ideas here...  How did you get the data into your
>> >> > DB?
>> >> > What happens if you call em.find(TUser.class, [known_id]) ? Could 
>> >> > you
>> >> > try
>> >> > creating some data and persisting it via JPA?
>> >> >
>> >> > Thanks,
>> >> > Rick
>> >> >
>> >>
>> >>
>> >>
>> >
>>
>>
>>
> 




Re: Can't obtain Primary Key value by JPQL

2010-11-05 Thread Rick Curtis
Can you point me to how you were enhancing your Entities... I'd like to get
to the bottom of this one.

Thanks,
Rick

On Fri, Nov 5, 2010 at 12:18 AM, Alex, Huang  wrote:

> Hi Rick,
>
> I got the reason. I always enhance entities by Eclipse plug-in.  After got
> your clue, I enhanced entities again by using command. And the problem
> disappeared.
>
> Really thank you for all the help.
> Alex, Huang
>
> - Original Message -
> From: "Rick Curtis" 
> To: 
> Sent: Friday, November 05, 2010 1:20 AM
> Subject: Re: Can't obtain Primary Key value by JPQL
>
>
> > How are you enhancing your Entities? If you are using build time, can you
> > post the enhanced .class file?
> >
> > Thanks,
> > Rick
> >
> > On Wed, Nov 3, 2010 at 8:32 PM, Alex, Huang 
> wrote:
> >
> >> Hi Rick,
> >>
> >> >How did you get the data into your DB?
> >> I  insert data at mysql prompt.
> >> 
> >> mysql> INSERT INTO t_user(name,age) VALUES ('John', 26);
> >> Query OK, 1 row affected (0.03 sec)
> >> 
> >>
> >> Now,db's data like below,
> >> 
> >> mysql> select * from t_user;
> >> +-++-+
> >> | uid | name   | age |
> >> +-++-+
> >> |   1 | Huang  |  26 |
> >> |   2 | Alex   |  28 |
> >> |   3 | tester |  22 |
> >> |   4 | John   |  26 |
> >> +-++-+
> >> 4 rows in set (0.00 sec)
> >> 
> >>
> >> >What happens if you call em.find(TUser.class, [known_id]) ?
> >>
> >> I run the following case, and it completed successful.
> >> 
> >>  public void testFind(){
> >>  EntityManager em = emf.createEntityManager();
> >>  em.getTransaction().begin();
> >>   TUser user  = em.find(TUser.class, 2);
> >>  assertEquals("Alex", user.getName());
> >>  assertEquals(28, user.getAge());
> >>  }
> >> 
> >>
> >> After  I added "assertEquals(2,user.getUid());", AssertionFailedError
> >> occured.
> >> 
> >> junit.framework.AssertionFailedError: expected:<2> but was:<0>
> >> 
> >>
> >> >Could you try creating some data and persisting it via JPA?
> >> OK.I added a method to test case.
> >> ==
> >>  public void testInsert(){
> >>   EntityManager em = emf.createEntityManager();
> >>  em.getTransaction().begin();
> >>   TUser user = new TUser();
> >>  user.setName("Jeason");
> >>  user.setAge(27);
> >>  em.persist(user);
> >>  em.getTransaction().commit();
> >>  em.close();
> >>  }
> >> ==
> >>
> >> I run the test case and it completed successful. At mysql prompt I
> >> confirmed
> >> the data has been created.
> >>
> >> ==
> >> mysql> select * from t_user;
> >> +-++-+
> >> | uid | name   | age |
> >> +-++-+
> >> |   1 | Huang  |  26 |
> >> |   2 | Alex   |  28 |
> >> |   3 | tester |  22 |
> >> |   4 | John   |  26 |
> >> |   5 | Jeason |  27 |
> >> +-++-+
> >> 5 rows in set (0.00 sec)
> >> ==
> >>
> >> Look forward to your advance.
> >> Alex,Huang
> >> - Original Message -
> >> From: "Rick Curtis" 
> >> To: 
> >> Sent: Thursday, November 04, 2010 5:29 AM
> >> Subject: Re: Can't obtain Primary Key value by JPQL
> >>
> >>
> >> > That looks about identical to the test case that I came up with.
> >> >
> >> >> Any advice?
> >> > I'm running low on ideas here...  How did you get the data into your
> >> > DB?
> >> > What happens if you call em.find(TUser.class, [known_id]) ? Could you
> >> > try
> >> > creating some data and persisting it via JPA?
> >> >
> >> > Thanks,
> >> > Rick
> >> >
> >>
> >>
> >>
> >
>
>
>


RE: Can't obtain Primary Key value by JPQL

2010-11-04 Thread C N Davies
Build time enhancement is the only method I ever trust, plugins and runtime
enhancement has taken years off my life :)

2c from me!

Chris


-Original Message-
From: Alex, Huang [mailto:primemo...@gmail.com] 
Sent: Friday, 5 November 2010 4:19 PM
To: users@openjpa.apache.org
Subject: Re: Can't obtain Primary Key value by JPQL

Hi Rick,

I got the reason. I always enhance entities by Eclipse plug-in.  After got
your clue, I enhanced entities again by using command. And the problem
disappeared.

Really thank you for all the help.
Alex, Huang

- Original Message -
From: "Rick Curtis" 
To: 
Sent: Friday, November 05, 2010 1:20 AM
Subject: Re: Can't obtain Primary Key value by JPQL


> How are you enhancing your Entities? If you are using build time, can you
> post the enhanced .class file?
>
> Thanks,
> Rick
>
> On Wed, Nov 3, 2010 at 8:32 PM, Alex, Huang  wrote:
>
>> Hi Rick,
>>
>> >How did you get the data into your DB?
>> I  insert data at mysql prompt.
>> 
>> mysql> INSERT INTO t_user(name,age) VALUES ('John', 26);
>> Query OK, 1 row affected (0.03 sec)
>> 
>>
>> Now,db's data like below,
>> 
>> mysql> select * from t_user;
>> +-++-+
>> | uid | name   | age |
>> +-++-+
>> |   1 | Huang  |  26 |
>> |   2 | Alex   |  28 |
>> |   3 | tester |  22 |
>> |   4 | John   |  26 |
>> +-++-+
>> 4 rows in set (0.00 sec)
>> 
>>
>> >What happens if you call em.find(TUser.class, [known_id]) ?
>>
>> I run the following case, and it completed successful.
>> 
>>  public void testFind(){
>>  EntityManager em = emf.createEntityManager();
>>  em.getTransaction().begin();
>>   TUser user  = em.find(TUser.class, 2);
>>  assertEquals("Alex", user.getName());
>>  assertEquals(28, user.getAge());
>>  }
>> 
>>
>> After  I added "assertEquals(2,user.getUid());", AssertionFailedError
>> occured.
>> 
>> junit.framework.AssertionFailedError: expected:<2> but was:<0>
>> 
>>
>> >Could you try creating some data and persisting it via JPA?
>> OK.I added a method to test case.
>> ==
>>  public void testInsert(){
>>   EntityManager em = emf.createEntityManager();
>>  em.getTransaction().begin();
>>   TUser user = new TUser();
>>  user.setName("Jeason");
>>  user.setAge(27);
>>  em.persist(user);
>>  em.getTransaction().commit();
>>  em.close();
>>  }
>> ==
>>
>> I run the test case and it completed successful. At mysql prompt I
>> confirmed
>> the data has been created.
>>
>> ==
>> mysql> select * from t_user;
>> +-+----+-+
>> | uid | name   | age |
>> +-++-+
>> |   1 | Huang  |  26 |
>> |   2 | Alex   |  28 |
>> |   3 | tester |  22 |
>> |   4 | John   |  26 |
>> |   5 | Jeason |  27 |
>> +-++-+
>> 5 rows in set (0.00 sec)
>> ==
>>
>> Look forward to your advance.
>> Alex,Huang
>> - Original Message -
>> From: "Rick Curtis" 
>> To: 
>> Sent: Thursday, November 04, 2010 5:29 AM
>> Subject: Re: Can't obtain Primary Key value by JPQL
>>
>>
>> > That looks about identical to the test case that I came up with.
>> >
>> >> Any advice?
>> > I'm running low on ideas here...  How did you get the data into your 
>> > DB?
>> > What happens if you call em.find(TUser.class, [known_id]) ? Could you 
>> > try
>> > creating some data and persisting it via JPA?
>> >
>> > Thanks,
>> > Rick
>> >
>>
>>
>>
> 




Re: Can't obtain Primary Key value by JPQL

2010-11-04 Thread Alex, Huang
Hi Rick,

I got the reason. I always enhance entities by Eclipse plug-in.  After got 
your clue, I enhanced entities again by using command. And the problem 
disappeared.

Really thank you for all the help.
Alex, Huang

- Original Message - 
From: "Rick Curtis" 
To: 
Sent: Friday, November 05, 2010 1:20 AM
Subject: Re: Can't obtain Primary Key value by JPQL


> How are you enhancing your Entities? If you are using build time, can you
> post the enhanced .class file?
>
> Thanks,
> Rick
>
> On Wed, Nov 3, 2010 at 8:32 PM, Alex, Huang  wrote:
>
>> Hi Rick,
>>
>> >How did you get the data into your DB?
>> I  insert data at mysql prompt.
>> 
>> mysql> INSERT INTO t_user(name,age) VALUES ('John', 26);
>> Query OK, 1 row affected (0.03 sec)
>> 
>>
>> Now,db's data like below,
>> 
>> mysql> select * from t_user;
>> +-++-+
>> | uid | name   | age |
>> +-++-+
>> |   1 | Huang  |  26 |
>> |   2 | Alex   |  28 |
>> |   3 | tester |  22 |
>> |   4 | John   |  26 |
>> +-++-+
>> 4 rows in set (0.00 sec)
>> 
>>
>> >What happens if you call em.find(TUser.class, [known_id]) ?
>>
>> I run the following case, and it completed successful.
>> 
>>  public void testFind(){
>>  EntityManager em = emf.createEntityManager();
>>  em.getTransaction().begin();
>>   TUser user  = em.find(TUser.class, 2);
>>  assertEquals("Alex", user.getName());
>>  assertEquals(28, user.getAge());
>>  }
>> 
>>
>> After  I added "assertEquals(2,user.getUid());", AssertionFailedError
>> occured.
>> 
>> junit.framework.AssertionFailedError: expected:<2> but was:<0>
>> 
>>
>> >Could you try creating some data and persisting it via JPA?
>> OK.I added a method to test case.
>> ==
>>  public void testInsert(){
>>   EntityManager em = emf.createEntityManager();
>>  em.getTransaction().begin();
>>   TUser user = new TUser();
>>  user.setName("Jeason");
>>  user.setAge(27);
>>  em.persist(user);
>>  em.getTransaction().commit();
>>  em.close();
>>  }
>> ==
>>
>> I run the test case and it completed successful. At mysql prompt I
>> confirmed
>> the data has been created.
>>
>> ==
>> mysql> select * from t_user;
>> +-----+----+-+
>> | uid | name   | age |
>> +-++-+
>> |   1 | Huang  |  26 |
>> |   2 | Alex   |  28 |
>> |   3 | tester |  22 |
>> |   4 | John   |  26 |
>> |   5 | Jeason |  27 |
>> +-++-+
>> 5 rows in set (0.00 sec)
>> ==
>>
>> Look forward to your advance.
>> Alex,Huang
>> - Original Message -
>> From: "Rick Curtis" 
>> To: 
>> Sent: Thursday, November 04, 2010 5:29 AM
>> Subject: Re: Can't obtain Primary Key value by JPQL
>>
>>
>> > That looks about identical to the test case that I came up with.
>> >
>> >> Any advice?
>> > I'm running low on ideas here...  How did you get the data into your 
>> > DB?
>> > What happens if you call em.find(TUser.class, [known_id]) ? Could you 
>> > try
>> > creating some data and persisting it via JPA?
>> >
>> > Thanks,
>> > Rick
>> >
>>
>>
>>
> 




Re: Can't obtain Primary Key value by JPQL

2010-11-04 Thread Rick Curtis
How are you enhancing your Entities? If you are using build time, can you
post the enhanced .class file?

Thanks,
Rick

On Wed, Nov 3, 2010 at 8:32 PM, Alex, Huang  wrote:

> Hi Rick,
>
> >How did you get the data into your DB?
> I  insert data at mysql prompt.
> 
> mysql> INSERT INTO t_user(name,age) VALUES ('John', 26);
> Query OK, 1 row affected (0.03 sec)
> 
>
> Now,db's data like below,
> 
> mysql> select * from t_user;
> +-++-+
> | uid | name   | age |
> +-++-+
> |   1 | Huang  |  26 |
> |   2 | Alex   |  28 |
> |   3 | tester |  22 |
> |   4 | John   |  26 |
> +-++-+
> 4 rows in set (0.00 sec)
> 
>
> >What happens if you call em.find(TUser.class, [known_id]) ?
>
> I run the following case, and it completed successful.
> 
>  public void testFind(){
>  EntityManager em = emf.createEntityManager();
>  em.getTransaction().begin();
>   TUser user  = em.find(TUser.class, 2);
>  assertEquals("Alex", user.getName());
>  assertEquals(28, user.getAge());
>  }
> 
>
> After  I added "assertEquals(2,user.getUid());", AssertionFailedError
> occured.
> 
> junit.framework.AssertionFailedError: expected:<2> but was:<0>
> 
>
> >Could you try creating some data and persisting it via JPA?
> OK.I added a method to test case.
> ==
>  public void testInsert(){
>   EntityManager em = emf.createEntityManager();
>  em.getTransaction().begin();
>   TUser user = new TUser();
>  user.setName("Jeason");
>  user.setAge(27);
>  em.persist(user);
>  em.getTransaction().commit();
>  em.close();
>  }
> ==
>
> I run the test case and it completed successful. At mysql prompt I
> confirmed
> the data has been created.
>
> ==
> mysql> select * from t_user;
> +-++-+
> | uid | name   | age |
> +-++-+
> |   1 | Huang  |  26 |
> |   2 | Alex   |  28 |
> |   3 | tester |  22 |
> |   4 | John   |  26 |
> |   5 | Jeason |  27 |
> +-----+----+-+
> 5 rows in set (0.00 sec)
> ==
>
> Look forward to your advance.
> Alex,Huang
> - Original Message -
> From: "Rick Curtis" 
> To: 
> Sent: Thursday, November 04, 2010 5:29 AM
> Subject: Re: Can't obtain Primary Key value by JPQL
>
>
> > That looks about identical to the test case that I came up with.
> >
> >> Any advice?
> > I'm running low on ideas here...  How did you get the data into your DB?
> > What happens if you call em.find(TUser.class, [known_id]) ? Could you try
> > creating some data and persisting it via JPA?
> >
> > Thanks,
> > Rick
> >
>
>
>


Re: Can't obtain Primary Key value by JPQL

2010-11-03 Thread Alex, Huang
Hi Rick,

>How did you get the data into your DB?
I  insert data at mysql prompt.

mysql> INSERT INTO t_user(name,age) VALUES ('John', 26);
Query OK, 1 row affected (0.03 sec)


Now,db's data like below,

mysql> select * from t_user;
+-++-+
| uid | name   | age |
+-++-+
|   1 | Huang  |  26 |
|   2 | Alex   |  28 |
|   3 | tester |  22 |
|   4 | John   |  26 |
+-++-+
4 rows in set (0.00 sec)


>What happens if you call em.find(TUser.class, [known_id]) ?

I run the following case, and it completed successful.

 public void testFind(){
  EntityManager em = emf.createEntityManager();
  em.getTransaction().begin();
  TUser user  = em.find(TUser.class, 2);
  assertEquals("Alex", user.getName());
  assertEquals(28, user.getAge());
 }


After  I added "assertEquals(2,user.getUid());", AssertionFailedError 
occured.

junit.framework.AssertionFailedError: expected:<2> but was:<0>


>Could you try creating some data and persisting it via JPA?
OK.I added a method to test case.
==
 public void testInsert(){
  EntityManager em = emf.createEntityManager();
  em.getTransaction().begin();
  TUser user = new TUser();
  user.setName("Jeason");
  user.setAge(27);
  em.persist(user);
  em.getTransaction().commit();
  em.close();
 }
==

I run the test case and it completed successful. At mysql prompt I confirmed 
the data has been created.

==
mysql> select * from t_user;
+-++-+
| uid | name   | age |
+-++-+
|   1 | Huang  |  26 |
|   2 | Alex   |  28 |
|   3 | tester |  22 |
|   4 | John   |  26 |
|   5 | Jeason |  27 |
+-++-+
5 rows in set (0.00 sec)
==

Look forward to your advance.
Alex,Huang
- Original Message - 
From: "Rick Curtis" 
To: 
Sent: Thursday, November 04, 2010 5:29 AM
Subject: Re: Can't obtain Primary Key value by JPQL


> That looks about identical to the test case that I came up with.
>
>> Any advice?
> I'm running low on ideas here...  How did you get the data into your DB?
> What happens if you call em.find(TUser.class, [known_id]) ? Could you try
> creating some data and persisting it via JPA?
>
> Thanks,
> Rick
> 




Re: Can't obtain Primary Key value by JPQL

2010-11-03 Thread Rick Curtis
That looks about identical to the test case that I came up with.

> Any advice?
I'm running low on ideas here...  How did you get the data into your DB?
What happens if you call em.find(TUser.class, [known_id]) ? Could you try
creating some data and persisting it via JPA?

Thanks,
Rick


Re: Can't obtain Primary Key value by JPQL

2010-11-03 Thread Alex, Huang
Hi Rick,

I wrote a small test case like below,
==START==
public class TestQuery extends SingleEMFTestCase {
 public void setUp() throws Exception {
  // registers TUser as persistence-capable entity
  super.setUp(TUser.class);
 }
 public void tearDown() throws Exception {
  //
 }
 public void testFind(){
  EntityManager em = emf.createEntityManager();
  em.getTransaction().begin();
  Query query = em.createQuery("SELECT user FROM TUser user",TUser.class);
  List result = query.getResultList();
  for( TUser entity: result){
   assertNotEquals(0, entity.getUid());
  }
 }
 public static void main(String[] args) {
  TestRunner.run(TestQuery.class);
 }
}
==END

And I got following error,

junit.framework.AssertionFailedError: expected args to be different; were 
the same instance.

Any advice?

Alex,Huang

>> - Original Message -
>> From: "Rick Curtis" 
>> To: 
>> Sent: Thursday, November 04, 2010 2:30 AM
>> Subject: Re: Can't obtain Primary Key value by JPQL
>>
>>
>> > Honesty, I don't have a clue why this isn't working for you. I have
>> > unsuccessfully tried to recreate this problem on both 2.0.x and trunk.
>> >
>> > Is it possible that you could write a small unit test to recreate the
>> > problem?
>> >
>> > Thanks,
>> > Rick
>> >
>>
>>
>>
> 




Re: Can't obtain Primary Key value by JPQL

2010-11-03 Thread Rick Curtis
Take a look at the testing page[1] ... that should get you rolling.

[1] http://openjpa.apache.org/testing.html

Thanks,
Rick

On Wed, Nov 3, 2010 at 1:40 PM, Alex, Huang  wrote:

> Hi Rick,
>
> Thanks a lot.
> I don't know how to write unit test to recreate the problem, would you give
> me a link or any sample?
>
> Alex,Huang
> - Original Message -
> From: "Rick Curtis" 
> To: 
> Sent: Thursday, November 04, 2010 2:30 AM
> Subject: Re: Can't obtain Primary Key value by JPQL
>
>
> > Honesty, I don't have a clue why this isn't working for you. I have
> > unsuccessfully tried to recreate this problem on both 2.0.x and trunk.
> >
> > Is it possible that you could write a small unit test to recreate the
> > problem?
> >
> > Thanks,
> > Rick
> >
>
>
>


Re: Can't obtain Primary Key value by JPQL

2010-11-03 Thread Alex, Huang
Hi Rick,

Thanks a lot.
I don't know how to write unit test to recreate the problem, would you give 
me a link or any sample?

Alex,Huang
- Original Message - 
From: "Rick Curtis" 
To: 
Sent: Thursday, November 04, 2010 2:30 AM
Subject: Re: Can't obtain Primary Key value by JPQL


> Honesty, I don't have a clue why this isn't working for you. I have
> unsuccessfully tried to recreate this problem on both 2.0.x and trunk.
>
> Is it possible that you could write a small unit test to recreate the
> problem?
>
> Thanks,
> Rick
> 




Re: Can't obtain Primary Key value by JPQL

2010-11-03 Thread Rick Curtis
Honesty, I don't have a clue why this isn't working for you. I have
unsuccessfully tried to recreate this problem on both 2.0.x and trunk.

Is it possible that you could write a small unit test to recreate the
problem?

Thanks,
Rick


Re: Can't obtain Primary Key value by JPQL

2010-11-03 Thread Alex, Huang
OK.
=
package entity;

import java.io.Serializable;
import javax.persistence.*;


/**
 * The persistent class for the t_user database table.
 *
 */
@Entity
@Table(name="t_user")
public class TUser implements Serializable {
 private static final long serialVersionUID = 1L;

 @Id
 @GeneratedValue(strategy=GenerationType.IDENTITY)
 @Column(insertable=false)
 private int uid;

 private int age;

 private String name;

public TUser() {
}

 public int getUid() {
  return this.uid;
 }

 public void setUid(int uid) {
  this.uid = uid;
 }

 public int getAge() {
  return this.age;
 }

 public void setAge(int age) {
  this.age = age;
 }

 public String getName() {
  return this.name;
 }

 public void setName(String name) {
  this.name = name;
 }

}

Thanks.
Alex,Huang
=
- Original Message - 
From: "Rick Curtis" 
To: 
Sent: Thursday, November 04, 2010 2:03 AM
Subject: Re: Can't obtain Primary Key value by JPQL


> Can you also post your entire Entity?
>
> Thanks,
> Rick
>
> On Wed, Nov 3, 2010 at 11:55 AM, Alex, Huang  wrote:
>
>> Hi Rick,
>>
>> Log:
>> ===START==
>> 188  JPATEST  INFO   [main] openjpa.Runtime - Starting OpenJPA 2.0.1
>> 3094  JPATEST  TRACE  [main] openjpa.jdbc.SQL - > 14220570>
>> executing prepstmnt 23932998 SELECT t0.uid, t0.age, t0.name FROM t_user 
>> t0
>> 3094  JPATEST  TRACE  [main] openjpa.jdbc.SQL - > 14220570>
>> [0 ms] spent
>> ===END
>>
>> Thanks in advance.
>> Alex,Huang
>>
>> ----- Original Message -
>> From: "Rick Curtis" 
>> To: 
>> Sent: Wednesday, November 03, 2010 11:21 PM
>> Subject: Re: Can't obtain Primary Key value by JPQL
>>
>>
>> > Can you post the SQL trace from when you execute your query?
>> >
>> > Thanks,
>> > Rick
>> >
>> > On Wed, Nov 3, 2010 at 3:51 AM, Alex, Huang 
>> wrote:
>> >
>> >> Hi everybody,
>> >>
>> >> I am using openJPA2.0.1 + Mysql5.1.
>> >>
>> >> Table definition like below,
>> >> ===DML START===
>> >> CREATE TABLE t_user (
>> >>  uid int(10) unsigned NOT NULL AUTO_INCREMENT,
>> >>  name varchar(255) DEFAULT NULL,
>> >>  age int(11) NOT NULL,
>> >>  PRIMARY KEY (uid)
>> >> ) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8;
>> >> ===DML END=
>> >>
>> >> entity,
>> >> ==Entity START=
>> >> @Entity
>> >> @Table(name="t_user")
>> >> public class TUser implements Serializable {
>> >>  private static final long serialVersionUID = 1L;
>> >>
>> >>  @Id
>> >>  @GeneratedValue(strategy=GenerationType.IDENTITY)
>> >>  @Column(insertable=false)
>> >>  private int uid;
>> >>
>> >>  private int age;
>> >>
>> >>  private String name;
>> >>  ..getter and setter.
>> >> ==Entity END===
>> >>
>> >> ==persistence.xml START===
>> >> 
>> >>  entity.TUser
>> >>  
>> >>   
>> >>   > >> value="com.mysql.jdbc.Driver"/>
>> >>   > >> value="jdbc:mysql://localhost:3306/test?characterEncoding=utf8"/>
>> >>   
>> >>   
>> >>   
>> >>  
>> >>
>> >> ==persistence.xml END=
>> >>
>> >>
>> >> I run a JPQL like below,
>> >>
>> >> Query query = em.createQuery("SELECT user FROM TUSER user");
>> >>
>> >> For the result, I can get each field's value except primary key field.
>> In
>> >> this case, each entity's uid field is zero.
>> >>
>> >> I tried to trace the source code and I found the following code in
>> >> org.apache.openjpa.jdbc.kernel.JDBCStoreManager from LINE 1085.
>> >>
>> >>// load unloaded fields
>> >>FieldMapping[] fms = mapping.getDefinedFieldMappings();
>> >>Object eres, processed;
>> >>for (int i = 0; i < fms.length; i++) {
>> >>if (fms[i].isPrimaryKey() ||
>> >> sm.getLoaded().get(fms[i].getIndex()))
>> >>continue;
>> >>
>> >> It seemed that if the a field is primary key so no value would be 
>> >> passed
>> >> to
>> >> it. Would someone tell me why?  Did I miss any setting?
>> >>
>> >> Thanks and best regards,
>> >> Alex, Huang
>> >>
>> >>
>> >>
>> >
>>
>>
>>
> 




Re: Can't obtain Primary Key value by JPQL

2010-11-03 Thread Rick Curtis
Can you also post your entire Entity?

Thanks,
Rick

On Wed, Nov 3, 2010 at 11:55 AM, Alex, Huang  wrote:

> Hi Rick,
>
> Log:
> ===START==
> 188  JPATEST  INFO   [main] openjpa.Runtime - Starting OpenJPA 2.0.1
> 3094  JPATEST  TRACE  [main] openjpa.jdbc.SQL - 
> executing prepstmnt 23932998 SELECT t0.uid, t0.age, t0.name FROM t_user t0
> 3094  JPATEST  TRACE  [main] openjpa.jdbc.SQL - 
> [0 ms] spent
> ===END
>
> Thanks in advance.
> Alex,Huang
>
> - Original Message -
> From: "Rick Curtis" 
> To: 
> Sent: Wednesday, November 03, 2010 11:21 PM
> Subject: Re: Can't obtain Primary Key value by JPQL
>
>
> > Can you post the SQL trace from when you execute your query?
> >
> > Thanks,
> > Rick
> >
> > On Wed, Nov 3, 2010 at 3:51 AM, Alex, Huang 
> wrote:
> >
> >> Hi everybody,
> >>
> >> I am using openJPA2.0.1 + Mysql5.1.
> >>
> >> Table definition like below,
> >> ===DML START===
> >> CREATE TABLE t_user (
> >>  uid int(10) unsigned NOT NULL AUTO_INCREMENT,
> >>  name varchar(255) DEFAULT NULL,
> >>  age int(11) NOT NULL,
> >>  PRIMARY KEY (uid)
> >> ) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8;
> >> ===DML END=
> >>
> >> entity,
> >> ==Entity START=
> >> @Entity
> >> @Table(name="t_user")
> >> public class TUser implements Serializable {
> >>  private static final long serialVersionUID = 1L;
> >>
> >>  @Id
> >>  @GeneratedValue(strategy=GenerationType.IDENTITY)
> >>  @Column(insertable=false)
> >>  private int uid;
> >>
> >>  private int age;
> >>
> >>  private String name;
> >>  ..getter and setter.
> >> ==Entity END===
> >>
> >> ==persistence.xml START===
> >> 
> >>  entity.TUser
> >>  
> >>   
> >>>> value="com.mysql.jdbc.Driver"/>
> >>>> value="jdbc:mysql://localhost:3306/test?characterEncoding=utf8"/>
> >>   
> >>   
> >>   
> >>  
> >>
> >> ==persistence.xml END=
> >>
> >>
> >> I run a JPQL like below,
> >>
> >> Query query = em.createQuery("SELECT user FROM TUSER user");
> >>
> >> For the result, I can get each field's value except primary key field.
> In
> >> this case, each entity's uid field is zero.
> >>
> >> I tried to trace the source code and I found the following code in
> >> org.apache.openjpa.jdbc.kernel.JDBCStoreManager from LINE 1085.
> >>
> >>// load unloaded fields
> >>FieldMapping[] fms = mapping.getDefinedFieldMappings();
> >>Object eres, processed;
> >>for (int i = 0; i < fms.length; i++) {
> >>if (fms[i].isPrimaryKey() ||
> >> sm.getLoaded().get(fms[i].getIndex()))
> >>continue;
> >>
> >> It seemed that if the a field is primary key so no value would be passed
> >> to
> >> it. Would someone tell me why?  Did I miss any setting?
> >>
> >> Thanks and best regards,
> >> Alex, Huang
> >>
> >>
> >>
> >
>
>
>


Re: Can't obtain Primary Key value by JPQL

2010-11-03 Thread Alex, Huang
Hi Rick,

Log:
===START==
188  JPATEST  INFO   [main] openjpa.Runtime - Starting OpenJPA 2.0.1
3094  JPATEST  TRACE  [main] openjpa.jdbc.SQL -  
executing prepstmnt 23932998 SELECT t0.uid, t0.age, t0.name FROM t_user t0
3094  JPATEST  TRACE  [main] openjpa.jdbc.SQL -  
[0 ms] spent
===END

Thanks in advance.
Alex,Huang

- Original Message - 
From: "Rick Curtis" 
To: 
Sent: Wednesday, November 03, 2010 11:21 PM
Subject: Re: Can't obtain Primary Key value by JPQL


> Can you post the SQL trace from when you execute your query?
>
> Thanks,
> Rick
>
> On Wed, Nov 3, 2010 at 3:51 AM, Alex, Huang  wrote:
>
>> Hi everybody,
>>
>> I am using openJPA2.0.1 + Mysql5.1.
>>
>> Table definition like below,
>> ===DML START===
>> CREATE TABLE t_user (
>>  uid int(10) unsigned NOT NULL AUTO_INCREMENT,
>>  name varchar(255) DEFAULT NULL,
>>  age int(11) NOT NULL,
>>  PRIMARY KEY (uid)
>> ) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8;
>> ===DML END=
>>
>> entity,
>> ==Entity START=
>> @Entity
>> @Table(name="t_user")
>> public class TUser implements Serializable {
>>  private static final long serialVersionUID = 1L;
>>
>>  @Id
>>  @GeneratedValue(strategy=GenerationType.IDENTITY)
>>  @Column(insertable=false)
>>  private int uid;
>>
>>  private int age;
>>
>>  private String name;
>>  ..getter and setter.
>> ==Entity END===
>>
>> ==persistence.xml START===
>> 
>>  entity.TUser
>>  
>>   
>>   > value="com.mysql.jdbc.Driver"/>
>>   > value="jdbc:mysql://localhost:3306/test?characterEncoding=utf8"/>
>>   
>>   
>>   
>>  
>>
>> ==persistence.xml END=
>>
>>
>> I run a JPQL like below,
>>
>> Query query = em.createQuery("SELECT user FROM TUSER user");
>>
>> For the result, I can get each field's value except primary key field. In
>> this case, each entity's uid field is zero.
>>
>> I tried to trace the source code and I found the following code in
>> org.apache.openjpa.jdbc.kernel.JDBCStoreManager from LINE 1085.
>>
>>// load unloaded fields
>>FieldMapping[] fms = mapping.getDefinedFieldMappings();
>>Object eres, processed;
>>for (int i = 0; i < fms.length; i++) {
>>if (fms[i].isPrimaryKey() ||
>> sm.getLoaded().get(fms[i].getIndex()))
>>continue;
>>
>> It seemed that if the a field is primary key so no value would be passed 
>> to
>> it. Would someone tell me why?  Did I miss any setting?
>>
>> Thanks and best regards,
>> Alex, Huang
>>
>>
>>
> 




Re: Can't obtain Primary Key value by JPQL

2010-11-03 Thread Rick Curtis
Can you post the SQL trace from when you execute your query?

Thanks,
Rick

On Wed, Nov 3, 2010 at 3:51 AM, Alex, Huang  wrote:

> Hi everybody,
>
> I am using openJPA2.0.1 + Mysql5.1.
>
> Table definition like below,
> ===DML START===
> CREATE TABLE t_user (
>  uid int(10) unsigned NOT NULL AUTO_INCREMENT,
>  name varchar(255) DEFAULT NULL,
>  age int(11) NOT NULL,
>  PRIMARY KEY (uid)
> ) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8;
> ===DML END=
>
> entity,
> ==Entity START=
> @Entity
> @Table(name="t_user")
> public class TUser implements Serializable {
>  private static final long serialVersionUID = 1L;
>
>  @Id
>  @GeneratedValue(strategy=GenerationType.IDENTITY)
>  @Column(insertable=false)
>  private int uid;
>
>  private int age;
>
>  private String name;
>  ..getter and setter.
> ==Entity END===
>
> ==persistence.xml START===
> 
>  entity.TUser
>  
>   
>value="com.mysql.jdbc.Driver"/>
>value="jdbc:mysql://localhost:3306/test?characterEncoding=utf8"/>
>   
>   
>   
>  
>
> ==persistence.xml END=
>
>
> I run a JPQL like below,
>
> Query query = em.createQuery("SELECT user FROM TUSER user");
>
> For the result, I can get each field's value except primary key field. In
> this case, each entity's uid field is zero.
>
> I tried to trace the source code and I found the following code in
> org.apache.openjpa.jdbc.kernel.JDBCStoreManager from LINE 1085.
>
>// load unloaded fields
>FieldMapping[] fms = mapping.getDefinedFieldMappings();
>Object eres, processed;
>for (int i = 0; i < fms.length; i++) {
>if (fms[i].isPrimaryKey() ||
> sm.getLoaded().get(fms[i].getIndex()))
>continue;
>
> It seemed that if the a field is primary key so no value would be passed to
> it. Would someone tell me why?  Did I miss any setting?
>
> Thanks and best regards,
> Alex, Huang
>
>
>