Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] Spikes, FOSS JPA 1.0 test framework

Hi John,

Shaun Smith wrote:
  
In terms of the problem you're addressing, things have changed since you 
wrote the article.
    
It's only a couple of week old!
  
No one can say we're sitting around doing nothing! ;-)
...
FYI, I have now updated Spikes to use TopLink Essentials, and there have
been a couple of problems:

1. Deliberately setting a non null field to null, and then attempting to
persist the object does not give back a Spring wrapped exception (as it does
in EclipseLink), but rather the infamous NPE trying to call hashCode - which
I assume means that TopLink is trying to put the object in its own cache,
without any 'formal' validation checks first - that's my hypothesis, more
than likely to be wrong. Here's a piece of the stack dump:
  
Can you post the class you're trying to persist and it's mappings?
...
2. Both TopLink and EclipseLink fail to update a @PreUpdate annotated method
when that method is not  public - when it's public things work just fine.
Yet the specs state that (section 3.5.1)

The callback methods can have public, private, protected, or package level
access, but must not be
static or final.

Here's the method:

	/**
	 * Settaggio della data del'ultimo aggiornamento prima del salvataggio -
	 * Sets the last updated date prior to saving.
	 */
	@PreUpdate 
	protected void preUpdate() {
		lastUpdated = new java.util.Date();
	}

Change protected to public and Robert is you proverbial father's brother.
This is not a showstopper of course, I'm personally not that squeemish about
making the method public.
  
I couldn't reproduce this problem with EclipseLink M7.  I began a transaction, queried an object, modified a String field, and committed the transaction.  I tried package, private, protected, and public.  Each time my @PreUpdate method was called.

    Shaun
John


Shaun Smith wrote:
  
     Shaun

John Leach wrote:
    
Dear list,
I have prepared a (very) small open source project to provide domain 
entity mapping and association examples, together with a programmatic 
interface to reach outside the JPA 1.0 specifications. Currently it 
works with Hibernate, EclipseLink and (almost, but not quite) OpenJPA.

The intention is to provide a 'third' alternative to annotations 
and/or persistence.xml, where the entity classes contain only JPA 
annotations, with any remaining changes being made programmatically. 
The one-to-many example defines CascadeType.ALL, but actually requires 
a 'delete-orphans' extension for the tests to succeed.

I had better warn you all that I am a freelance consultant working in 
Italy and I use and will be using this work to sell both the 
advantages and disadvantages (but with solutions) of using JPA 1.0. to 
my clients.

Although the EclipseLink part works, and the programmatic interface is 
quite simple (using the eclipselink.session.customizer property), 
working in a vacuum (that's me and myself, and we don't always agree) 
does mean that I'm never quite sure that I've found a "good enough" 
solution. Any help would be greatly appreciated. I am working 'in 
collaboration with' two Java User Groups (Torino and Trento), but it's 
really me who wrote most of the code.

The open source project, called Spikes (guess why) can be downloaded 
via Subversion with the command:

svn checkout https://lab.jugtorino.it/svn/sandbox/spikes/trunk spikes

There is a Trac site at 
http://lab.jugtorino.it/trac/sandbox/wiki/Spikes which I have 
converted to English in most places, and also an article (which 
started the project rolling) 
http://www.syger.it/Tutorials/JPA10Gotchas.html

Best regards
John Leach, Verona, Italy

_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users
      
-- 


Oracle <http://www.oracle.com>
Shaun Smith | Principal Product Manager, TopLink | +1.905.502.3094
Oracle Fusion Middleware
110 Matheson Boulevard West, Suite 100
Mississauga, Ontario, Canada L5R 3P4

_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users


    
  

--


Oracle
Shaun Smith | Principal Product Manager, TopLink | +1.905.502.3094
Oracle Fusion Middleware
110 Matheson Boulevard West, Suite 100
Mississauga, Ontario, Canada L5R 3P4

Back to the top