The pk is being assigned in the DB. When I look up the entity with the
EM, the pk is not set in the entity correctly. In fact it's 0 and I
would have expected null any way as its a java.lang.Long, not a
primitive ...  I will try the enable the logging again. I did put the
appropriate property in the persistence.xml but, WL is logging a
warning that it is going to be ignored and the logging should be
configured in the console. So I got into the console and enabled the
jpa logging but, I am not seeing anything.

Some more facts:

1) I am making remote calls into a session bean that is then
interacting with an injected EM. So the transaction demarcation should
be being controlled by the container at the session bean method level.
All the methods of the session bean are of transaction type requires
by default.

2) I am NOT using the WLs XA Sybase driver because I have to get the
DBAs to grant some role to make it work. So for now I am using WLs non
XA driver.

I am not positive that the EM is playing nice with JTA and maybe thats
why the pks are not being refreshed / loaded back from the db. Then
again the underlying inserts are committed.


On 3/4/07, Marc Prud'hommeaux <[EMAIL PROTECTED]> wrote:
Dan-

Once you commit the transaction, is the PK assigned? Can you enable
SQL logging any show us the SQL that is executed in the transaction?

Finally, if you look up the Entity using a new EntityManager, is the
PK set correctly?


On Mar 2, 2007, at 3:38 PM, Dan Bush wrote:

> I am using WL 10T and OpenJPA(0.9.7 nightly) against a Sybase(12.5.3)
> DB . My PK types are IDENTITY and I have the entities mapped like so:
>
>       @Id
>       @GeneratedValue(strategy = GenerationType.IDENTITY)
>       @Column(name = "myPk")
>       private Long id;
>
>       public Long getId() {    // i only have a setter ...
>               return id;
>       }
>
> When I execute the following code, the PK comes back 0! :
>
> Entity e = new EntityX();
>
> _em.persist(entity);
>
> // _em.flush();
> // _em.refresh() // tried this too
>
> System.out.println(entity.getId()); // returning 0
>
>
>
> It doesn't look like the PKs are being relayed back from the DB. Not
> sure if I have a driver issue or what(using the non XA WL Sybase
> driver). Even when I find an entity all the fields values seam to be
> working except for the pks. Anyone have any ideas?


Reply via email to