Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] lifecycle and validation annotations don't work in embeded classes

The JPA spec does not define event for Embeddables.

EclipseLink does support events on Embeddables if you use a
DescriptorEventListener set by a DescriptorCustomizer.  Please log a bug on
EclipseLink to have the event annotations supported by EclipseLink.

For the validation annotations, that is not part of JPA, but another
spec/product.  It should also be possible though I think, but it depends on
your validation provider.


marekpribyl wrote:
> 
> hello there,
> I have troubles to make JPA/validation annotations work in embeded class.
> Assume following simple example:
> 
> @Entity
> class Parent {
>   @NotNull
>   private String name;
> 
>   @Embeded @Valid
>   private Child child;
> 
>   @PrePersist
>   public void parentMethod() {...}
> 
>   ...getters/setters...
> }
> 
> @Embedable
> class Child extends AbstractChild {
>   @NotNull
>   private String name;
> 
>   @PrePersist
>   public void childMethod() {...}
> 
>   ...getters/setters...
> }
> 
> @MappedSuperclass
> abstract class AbstractChild {
>   ...
> 
>   @PrePersist
>   public void abstractChildMethod() {...}
> }
> 
> 
> when I run it as a JUnit test neither JPA lifecycle nor validation
> annotations defined in the embeded class work. on other hand these in the
> parent class work correctly.
> 
> My setup is:
> - Eclipselink 2.3.2
> - apache bval-jsr303 0.4 + geronimo-validation_1.0_spec
> - Spring 3.1.1
> 
> thanks in advance for any help
> marek
> 


-----
http://wiki.eclipse.org/User:James.sutherland.oracle.com James Sutherland 
http://www.eclipse.org/eclipselink/
 EclipseLink ,  http://www.oracle.com/technology/products/ias/toplink/
TopLink 
Wiki:  http://wiki.eclipse.org/EclipseLink EclipseLink , 
http://wiki.oracle.com/page/TopLink TopLink 
Forums:  http://forums.oracle.com/forums/forum.jspa?forumID=48 TopLink , 
http://www.eclipse.org/forums/index.php?t=thread&frm_id=111&S=1b00bfd151289b297688823a00683aca
EclipseLink 
Book:  http://en.wikibooks.org/wiki/Java_Persistence Java Persistence 
Blog:  http://java-persistence-performance.blogspot.com/ Java Persistence
Performance 
-- 
View this message in context: http://old.nabble.com/lifecycle-and-validation-annotations-don%27t-work-in-embeded-classes-tp33862645p33864534.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.



Back to the top