Re: javax.persistence.EntityListeners is never called

2014-10-17 Thread gouessej
I still have a compile error here, line 1583:
http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/AnnotationPersistenceMappingParser.java?view=markup

Adding a cast to Boolean seems to fix it but actually, it should work as is, 
Netbeans 7.4 (with Java 1.7) probably does something wrong. It claims that 
J2DoPrivHelper.isAnnotationPresentAction() returns a PrivilegedAction whereas 
it returns a PrivilegedAction.




 Message du 16/10/14 18:32
 De : Rick Curtis 
 A : users , goues...@orange.fr
 Copie à : 
 Objet : Re: javax.persistence.EntityListeners is never called
 
  I had to disable checkstyle and to fix a compile error to build OpenJPA.
 The test passes.
 Yes, sorry I just committed a fix for that. Please do an update and let me
 know if you're still having compile problems.
 
 I think that you should have a separate listener class and have the
 singleton bean injected into it.
 
 On Thu, Oct 16, 2014 at 11:08 AM,  wrote:
 
  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 , goues...@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 , goues...@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 , goues...@orange.fr
   Copie à :
   Objet : Re: 

Re: javax.persistence.EntityListeners is never called

2014-10-17 Thread gouessej
Please find enclosed my patch. It fixes the compile errors and it is better 
than a useless cast.

 Message du 16/10/14 18:32
 De : Rick Curtis 
 A : users , goues...@orange.fr
 Copie à : 
 Objet : Re: javax.persistence.EntityListeners is never called
 
  I had to disable checkstyle and to fix a compile error to build OpenJPA.
 The test passes.
 Yes, sorry I just committed a fix for that. Please do an update and let me
 know if you're still having compile problems.
 
 I think that you should have a separate listener class and have the
 singleton bean injected into it.
 
 On Thu, Oct 16, 2014 at 11:08 AM,  wrote:
 
  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 , goues...@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 , goues...@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 , goues...@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 

Re: javax.persistence.EntityListeners is never called

2014-10-17 Thread Rick Curtis
I don't see your patch... and I also don't see this same problem when
running in Eclipse.

What vendor / version of java are you running? I remember seeing similar
problems when running with early version of java 7 (or maybe it was 8.. I
don't really remember)

Is your original problem resolved?

On Fri, Oct 17, 2014 at 9:22 AM, goues...@orange.fr wrote:

 Please find enclosed my patch. It fixes the compile errors and it is
 better than a useless cast.

  Message du 16/10/14 18:32
  De : Rick Curtis
  A : users , goues...@orange.fr
  Copie à :
  Objet : Re: javax.persistence.EntityListeners is never called
 
   I had to disable checkstyle and to fix a compile error to build
 OpenJPA.
  The test passes.
  Yes, sorry I just committed a fix for that. Please do an update and let
 me
  know if you're still having compile problems.
 
  I think that you should have a separate listener class and have the
  singleton bean injected into it.
 
  On Thu, Oct 16, 2014 at 11:08 AM,  wrote:
 
   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 , goues...@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 , goues...@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 

Re: javax.persistence.EntityListeners is never called

2014-10-17 Thread gouessej
I use Oracle JDK 1.7 update 71 with Netbeans 7.4 under Windows when I'm at 
work. I use OpenJDK 1.7 under Mageia Linux 4 at home. My original problem isn't 
fixed yet. I enabled PostLoadOnMerge but it doesn't change anything.

My patch is here:
# This patch file was generated by NetBeans IDE
# Following Index: paths are relative to: C:\Users\jgouesse\Documents\trunk
# This patch can be applied using context Tools: Patch action on respective 
folder.
# It uses platform neutral UTF-8 encoding and \n newlines.
# Above lines and this line are ignored by the patching process.
Index: 
openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/AnnotationPersistenceMappingParser.java
--- 
openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/AnnotationPersistenceMappingParser.java
 Base (BASE)
+++ 
openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/AnnotationPersistenceMappingParser.java
 Locally Modified (Based On LOCAL)
@@ -1560,9 +1560,10 @@

// cache the JAXB XmlRootElement class if it is present so we do not
// have a hard-wired dependency on JAXB here
- Class xmlRootElementClass = null;
+ Class? extends Annotation xmlRootElementClass = null;
try {
- xmlRootElementClass = 
Class.forName(javax.xml.bind.annotation.XmlRootElement);
+ xmlRootElementClass = (Class? extends Annotation)
+ Class.forName(javax.xml.bind.annotation.XmlRootElement);
} catch (Exception e) {
}

Index: 
openjpa-persistence/src/main/java/org/apache/openjpa/persistence/AnnotationPersistenceXMLMetaDataParser.java
--- 
openjpa-persistence/src/main/java/org/apache/openjpa/persistence/AnnotationPersistenceXMLMetaDataParser.java
 Base (BASE)
+++ 
openjpa-persistence/src/main/java/org/apache/openjpa/persistence/AnnotationPersistenceXMLMetaDataParser.java
 Locally Modified (Based On LOCAL)
@@ -18,6 +18,7 @@
*/
package org.apache.openjpa.persistence;

+import java.lang.annotation.Annotation;
import java.lang.reflect.AnnotatedElement;
import java.lang.reflect.Field;
import java.lang.reflect.Member;
@@ -53,8 +54,8 @@

// cache the JAXB Xml... classes if they are present so we do not
// have a hard-wired dependency on JAXB here
- private Class xmlTypeClass = null;
- private Class xmlRootElementClass = null;
+ private Class? extends Annotation xmlTypeClass = null;
+ private Class? extends Annotation xmlRootElementClass = null;
private Class xmlAccessorTypeClass = null;
private Class xmlAttributeClass = null;
private Class xmlElementClass = null;
@@ -75,11 +76,11 @@
_conf = conf;
_log = conf.getLog(OpenJPAConfiguration.LOG_METADATA);
try {
- xmlTypeClass = Class.forName(
+ xmlTypeClass = (Class? extends Annotation) Class.forName(
javax.xml.bind.annotation.XmlType);
xmlTypeName = xmlTypeClass.getMethod(name, null);
xmlTypeNamespace = xmlTypeClass.getMethod(namespace, null);
- xmlRootElementClass = Class.forName(
+ xmlRootElementClass = (Class? extends Annotation) Class.forName(
javax.xml.bind.annotation.XmlRootElement);
xmlRootName = xmlRootElementClass.getMethod(name, null);
xmlRootNamespace = xmlRootElementClass.getMethod(namespace, null);







 Message du 17/10/14 17:02
 De : Rick Curtis 
 A : users , goues...@orange.fr
 Copie à : 
 Objet : Re: javax.persistence.EntityListeners is never called
 

I don't see your patch... and I also don't see this same problem when running 
in Eclipse. 


What vendor / version of java are you running? I remember seeing similar 
problems when running with early version of java 7 (or maybe it was 8.. I don't 
really remember)


Is your original problem resolved?



On Fri, Oct 17, 2014 at 9:22 AM,  wrote:

Please find enclosed my patch. It fixes the compile errors and it is better 
than a useless cast.
 
  Message du 16/10/14 18:32
  De : Rick Curtis
  A : users , goues...@orange.fr
  Copie à :
  Objet : Re: javax.persistence.EntityListeners is never called
 
   I had to disable checkstyle and to fix a compile error to build OpenJPA.
  The test passes.
  Yes, sorry I just committed a fix for that. Please do an update and let me
  know if you're still having compile problems.
 
  I think that you should have a separate listener class and have the
  singleton bean injected into it.
 
 

 On Thu, Oct 16, 2014 at 11:08 AM,  wrote:
 
   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 , goues...@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.