openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From goues...@orange.fr
Subject Re: javax.persistence.EntityListeners is never called
Date Thu, 16 Oct 2014 16:08:06 GMT
I had to disable checkstyle and to fix a compile error to build OpenJPA. The test passes.

However, the contract of the annotation javax.ejb.Singleton isn't respected by OpenEJB whereas
it is respected by Hibernate. This is the only difference that I have found. I just put a
log message into the constructor of the annotated class.




> Message du 15/10/14 17:25
> De : "Rick Curtis" 
> A : "users" , gouessej@orange.fr
> Copie à : 
> Objet : Re: javax.persistence.EntityListeners is never called
> 
> Yes, there are numerous unit tests, please take a look at the one that I've
> noted below.
> 
> https://svn.apache.org/repos/asf/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/callbacks/TestEntityListeners.java
> 
> On Wed, Oct 15, 2014 at 10:00 AM,  wrote:
> 
> > Are there any unit tests that I can run and modify to reproduce my
> > problem? This is typically what I do with JogAmp.
> >
> > > Message du 15/10/14 16:42
> > > De : "Rick Curtis"
> > > A : "users" , gouessej@orange.fr
> > > Copie à :
> > > Objet : Re: javax.persistence.EntityListeners is never called
> > >
> > > >Getting rid of this property doesn't solve my problem.
> > > Sorry about muddying the waters. As I stated, that suggestion isn't
> > related
> > > to the current problem... it is a best practice. That property is busted
> > > and you can fairly easily get into deadlocks.
> > >
> > > I am still confused The reason @PostLoad isn't called is because your
> > > snippets look good. Can I have you put together some sort of a
> > recreatable
> > > test? That will help speed up diagnosis.
> > >
> > > Thanks,
> > > Rick
> > >
> > > On Wed, Oct 15, 2014 at 4:35 AM, wrote:
> > >
> > > > Getting rid of this property doesn't solve my problem.
> > > >
> > > > My listener:
> > > >
> > > > @Singleton
> > > > public class MultiLangStringEntityListener {
> > > >
> > > > @PostLoad
> > > > @SuppressWarnings("UseSpecificCatch")
> > > > public void postLoad(Object entity) {
> > > >
> > > >
> > > > An entity:
> > > > @Entity
> > > > @EntityListeners({MultiLangStringEntityListener.class})
> > > > @Table(name = "THEME")
> > > > @XmlRootElement(name = "Theme")
> > > > @NamedQueries({
> > > > @NamedQuery(name = "DmTheme.findAll", query = "SELECT d FROM DmTheme
> > d")})
> > > > public class Theme implements Serializable {
> > > > private static final long serialVersionUID = 1L;
> > > > // @Max(value=?) @Min(value=?)//if you know range of your decimal
> > fields
> > > > consider using these annotations to enforce field validation
> > > > @Id
> > > > @Basic(optional = false)
> > > > @GeneratedValue(strategy = GenerationType.SEQUENCE, generator =
> > > > "SEQ_THEME")
> > > > @SequenceGenerator(name = "SEQ_THEME", sequenceName = "SEQ_THEME",
> > > > allocationSize = 1)
> > > > @Column(name = "ID")
> > > > private BigInteger id;
> > > > @Embedded
> > > > @AttributeOverrides({
> > > > @AttributeOverride(name = "id", column = @Column(name = "DESCR",
> > > > nullable=false)),
> > > > @AttributeOverride(name = "lang", column = @Column(insertable = false,
> > > > updatable = false, name = "DESCR")),
> > > > @AttributeOverride(name = "text", column = @Column(insertable = false,
> > > > updatable = false, name = "DESCR"))
> > > > })
> > > > private MultiLangString descr;
> > > >
> > > >
> > > > The embeddable class:
> > > >
> > > > @Embeddable
> > > > public class MultiLangString implements Serializable {
> > > >
> > > > private static final long serialVersionUID = 1L;
> > > > private String id;
> > > > private String lang;
> > > > private String text;
> > > >
> > > > public MultiLangString() {
> > > > }
> > > >
> > > >
> > > > Some of my entity classes use both @Embedded and @EmbeddedId but not on
> > > > the same field. I don't know what is wrong as it still works with
> > Hibernate
> > > > whereas I try to stay far from its specific features as you can see in
> > this
> > > > bug report:
> > > > https://hibernate.atlassian.net/browse/HHH-9437
> > > >
> > > >
> > > > > Message du 14/10/14 17:45
> > > > > De : "Rick Curtis"
> > > > > A : "users" , gouessej@orange.fr
> > > > > Copie à :
> > > > > Objet : Re: javax.persistence.EntityListeners is never called
> > > > >
> > > > > One thing that jumps out of your p.xml is the openjpa.Multithreaded
> > > > > property. I suggest you get rid of that property and ensure that
you
> > > > aren't
> > > > > sharing EntityManager's across threads... but I don't think that
is
> > > > related
> > > > > to the problem you are currently having.
> > > > >
> > > > > Can you post relevant snippets of your Entity?
> > > > >
> > > > > On Tue, Oct 14, 2014 at 10:39 AM, wrote:
> > > > >
> > > > > > Sorry for the confusion. No I'm not using those callbacks on
an
> > > > Embeddable
> > > > > > but when I switched to OpenJPA, I remember that I had to add
the
> > > > classes
> > > > > > with @Embeddable into persistence.xml whereas it wasn't necessary
> > with
> > > > > > Hibernate.
> > > > > >
> > > > > > The class that uses those callbacks uses the annotation @Singleton,
> > > > > > removing it doesn't solve my problem.
> > > > > >
> > > > > > Please find enclosed the file.
> > > > > >
> > > > > >
> > > > > > > Message du 14/10/14 17:31
> > > > > > > De : "Rick Curtis"
> > > > > > > A : "users" , gouessej@orange.fr
> > > > > > > Copie à :
> > > > > > > Objet : Re: javax.persistence.EntityListeners is never
called
> > > > > > >
> > > > > > >
> > > > > > 2.4.x is the latest.
> > > > > >
> > > > > > >
> > > > > > If I understand your previous posts, are you using
> > callbacks(@Preload,
> > > > > > @Postload, etc, etc) on an Embeddable? If that is the case,
I'm not
> > > > sure if
> > > > > > it is suppose to work? Can I have you post some Entity/embeddable
> > > > snippets
> > > > > > so we can better understand what you want to do?
> > > > > >
> > > > > > >
> > > > > > Thanks,
> > > > > > Rick
> > > > > > >
> > > > > >
> > > > > > >
> > > > > >
> > > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > > >
> > > > > > On Tue, Oct 14, 2014 at 8:20 AM, wrote:
> > > > > > >
> > > > > > I use OpenJPA 2.4.0. I'm going to try with a more recent version
if
> > > > any.
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > > Message du 14/10/14 00:14
> > > > > > > > De : "Kevin Sutter"
> > > > > > > > A : users@openjpa.apache.org, gouessej@orange.fr
> > > > > > > > Copie à :
> > > > > > > > Objet : Re: javax.persistence.EntityListeners is never
called
> > > > > > > >
> > > > > > > > Hi,
> > > > > > > > The complete trace can be turned on via this property
in your
> > > > p.xml:
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > Good luck,
> > > > > > > > Kevin
> > > > > > >
> > > > > >
> > > > > > >
> > > > > > > > On Mon, Oct 13, 2014 at 1:01 PM, wrote:
> > > > > > > >
> > > > > > > > > Hi
> > > > > > > > >
> > > > > > > > > I use Apache OpenEJB 4.7.1 (probably OpenJPA
2.2 or 2.3). I
> > have
> > > > > > looked at
> > > > > > > > > the logs and I have already done my best to force
the
> > > > persistence of
> > > > > > all
> > > > > > > > > entity classes including those Hibernate was
able to discover
> > > > alone,
> > > > > > for
> > > > > > > > > example the class using @Embeddable. As I'm currently
not at
> > > > work, I
> > > > > > can't
> > > > > > > > > post the persistence.xml but I'll do it tomorrow.
What
> > should I
> > > > turn
> > > > > > on to
> > > > > > > > > get some more trace? Thank you for your help.
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > > Message du 13/10/14 19:07
> > > > > > > > > > De : "Kevin Sutter"
> > > > > > > > > > A : users@openjpa.apache.org, gouessej@orange.fr
> > > > > > > > > > Copie à :
> > > > > > > > > > Objet : Re: javax.persistence.EntityListeners
is never
> > called
> > > > > > > > > >
> > > > > > > > > > Hi,
> > > > > > > > > > EntityListeners should work just fine with
OpenJPA. What
> > > > version of
> > > > > > > > > > OpenJPA are you using? The basic support
is documented
> > here:
> > > > > > > > > >
> > > > > > > > >
> > > > > >
> > > >
> > http://ci.apache.org/projects/openjpa/trunk/docbook/manual.html#jpa_overview_pc_callbacks
> > > > > > > > > >
> > > > > > > > > > Are there any other messages in the logs
that indicate an
> > > > issue?
> > > > > > Have you
> > > > > > > > > > tried turning on Trace to ensure that normal
persistence
> > > > > > processing is
> > > > > > > > > > happening? Can you post your p.xml? Like
I mentioned, this
> > > > should
> > > > > > all
> > > > > > > > > > just work. We'll need a bit more context
to help figure
> > out the
> > > > > > problem.
> > > > > > > > > >
> > > > > > > > > > Kevin
> > > > > > > > > >
> > > > > > > > > > On Mon, Oct 13, 2014 at 10:56 AM, wrote:
> > > > > > > > > >
> > > > > > > > > > > Hello
> > > > > > > > > > >
> > > > > > > > > > > I use javax.persistence.EntityListeners.
The persistent
> > > > classes
> > > > > > of the
> > > > > > > > > > > entities are correctly added into persistence.xml.
My
> > test
> > > > case
> > > > > > works
> > > > > > > > > > > correctly with Hibernate and OpenJPA
except that the
> > > > annotated
> > > > > > methods
> > > > > > > > > > > (with @PostLoad, @PreUpdate, @PrePersist
and
> > @PostRemove) are
> > > > > > never
> > > > > > > > > called
> > > > > > > > > > > by OpenJPA whereas they are called
by Hibernate. Am I
> > missing
> > > > > > anything
> > > > > > > > > > > obvious? Best regards.
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > > >
> > > > > >
> > > > > > >
> > > > > > --
> > > > > > > Rick Curtis
> > > > > > >
> > > > > >
> > > > >
> > > > >
> > > > >
> > > > > --
> > > > > *Rick Curtis*
> > > > >
> > > >
> > >
> > >
> > >
> > > --
> > > *Rick Curtis*
> > >
> >
> 
> 
> 
> -- 
> *Rick Curtis*
>

Mime
View raw message