Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Sharing using information with an entity listener
Sharing using information with an entity listener [message #551010] Wed, 04 August 2010 16:12 Go to next message
Mauro Flores is currently offline Mauro Flores
Messages: 84
Registered: September 2009
Location: Brasil
Member
The following code is a correct and good aproach to pass the name of the system user to an entity listener?

// My bussiness code:
...
Session unitOfWork =  JpaHelper.getEntityManager(em).getUnitOfWork(); 
unitOfWork.setProperty("user", user);	 
em.merge(entity); 
...


// My entity listener code: 
class MyEntityListener extends DescriptorEventAdapter {

 @Override
  public void preUpdateWithChanges(DescriptorEvent event) {
    Session unitOfWork = event.getSession();  
System.out.println("User doing the merge  = " +  unitOfWork.getProperty("user"));
  }


Thaks for some help. Mauro.
Re: Sharing using information with an entity listener [message #551779 is a reply to message #551010] Mon, 09 August 2010 10:19 Go to previous message
James Sutherland is currently offline James Sutherland
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

Seems fine.


James : Wiki : Book : Blog : Twitter
Previous Topic:Difficulties Unmarshalling Timestamp
Next Topic:Eclipselink and JBoss 5.1 java.net.MalformedURLException
Goto Forum:
  


Current Time: Thu Aug 28 03:31:51 EDT 2014

Powered by FUDForum. Page generated in 0.06420 seconds