Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Configuring TimestampLockingPolicy via JPA Persistence Unit Property(JPA configuration)
Configuring TimestampLockingPolicy via JPA Persistence Unit Property [message #1220409] Wed, 11 December 2013 14:54 Go to next message
J H is currently offline J HFriend
Messages: 2
Registered: December 2013
Junior Member
I recently came across the TimestampLockingPolicy class which allows setting of version timestamp source (data source or local) when using optimistic locking.

The wiki page http://wiki.eclipse.org/EclipseLink/Examples/JPA/Locking mentions that the behavior can be configured.
I have looked around, even checked the source code but have not found a way to configure the policy from within a JPA project (running inside Glassfish 3 server).

I just wonder if I can configure the behavior via a Persistence Unit property.
Or is there another way to do it within a JPA project?

Thanks a lot,
J
Re: Configuring TimestampLockingPolicy via JPA Persistence Unit Property [message #1220540 is a reply to message #1220409] Thu, 12 December 2013 13:00 Go to previous messageGo to next message
Lukas JungmannFriend
Messages: 36
Registered: November 2013
Location: Prague, Czech Republic
Member
Hi,
this can be configured using DescriptorCustomizer (or eventually using SessionCustomizer), ie this way:

@Entity
@Customizer(Cust.class)
public class MyEntity {
...

or in persistence xml using:
      <property name="eclipselink.descriptor.customizer.NewEntity" value="<pkg>.Cust"/>

where Cust.java looks like:
public class Cust implements DescriptorCustomizer {

    @Override
    public void customize(ClassDescriptor cd) throws Exception {
        //TODO: error handling
        TimestampLockingPolicy tlp = (TimestampLockingPolicy) cd.getOptimisticLockingPolicy();
        tlp.useLocalTime();
    }   
}

HTH,
--lukas
Re: Configuring TimestampLockingPolicy via JPA Persistence Unit Property [message #1220981 is a reply to message #1220540] Mon, 16 December 2013 13:19 Go to previous message
J H is currently offline J HFriend
Messages: 2
Registered: December 2013
Junior Member
Hi Lukas,

thanks a lot for your reply. That was exactly what I have been looking for. Great!

Thanks!
J
Previous Topic:Update entity with relation to persistent entity
Next Topic:Bug or misunderstanding ?
Goto Forum:
  


Current Time: Tue Apr 23 17:33:01 GMT 2024

Powered by FUDForum. Page generated in 0.03544 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top