facebook

JPA Validator Ignores Inner Classes

  1. MyEclipse Archived
  2.  > 
  3. Bugs
Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #281222 Reply

    In MyEclipse 6.0.1, the JPA validator does not seem to validate entities that are inner classes of other entities. In the code below, the comments show the warnings raised by the validator. This code represents a valid entity relationship, and is handled correctly by Hibernate. If the Inner class is moved outside of the Outer class, the validator works correctly.

    Outer.java

    import java.util.*;
    import javax.persistence.*;
    
    @Entity public class Outer {
        @Entity public static class Inner {
            @Id @GeneratedValue protected Long id;
    
            @ManyToOne protected Outer outer;
    
            public Long getId() {
                return id;
            }
    
            public Outer getOuter() {
                return outer;
            }
    
            public void setOuter(Outer outer) {
                this.outer = outer;
            }
        }
    
        @Id @GeneratedValue protected Long id;
    
        // MappedBy specified for inners does not exist on the target entity class
        // Target Outer.Inner.class is not an entity
        @OneToMany(mappedBy = "outer") protected Set<Inner> inners;
    
        public Long getId() {
            return id;
        }
    
        public Set<Inner> getInners() {
            return inners;
        }
    
        public void setInners(Set<Inner> inners) {
            this.inners = inners;
        }
    }
    #281277 Reply

    Loyal Water
    Member

    I was able to reproduce this warning at my end as well. I have logged this for my dev team. I’ll get back to you with an update as soon as possible. Thank you for bringing this up.

    #281283 Reply

    While doing some additional testing, I noticed that the validator also ignores fully-qualified annotations. The code below generates no errors or warnings from the validator.

    Outer.java

    import java.util.*;
    
    @javax.persistence.Entity public class Outer {
       @javax.persistence.Entity public static class Inner {
          @javax.persistence.Id @javax.persistence.GeneratedValue protected Long id;
    
          @javax.persistence.ManyToOne protected Outer outer;
    
          public Long getId() {
             return id;
          }
    
          public Outer getOuter() {
             return outer;
          }
    
          public void setOuter(Outer outer) {
             this.outer = outer;
          }
       }
    
       @javax.persistence.Id @javax.persistence.GeneratedValue protected Long id;
    
       @javax.persistence.OneToMany(mappedBy = "outer") protected Set<Inner> inners;
    
       public Long getId() {
          return id;
       }
    
       public Set<Inner> getInners() {
          return inners;
       }
    
       public void setInners(Set<Inner> inners) {
          this.inners = inners;
       }
    }
    #281297 Reply

    Loyal Water
    Member

    Can you go to MyEclipse > Installation Summary > Installation Details and paste the installation information here for me as well. I just want to make sure all this is being tested on the same version of MyEclipse as yours.

    #281311 Reply

    I’ve confirmed the behavior in Windows:

    *** Date: 
    Wednesday, January 30, 2008 4:24:18 PM EST
    
    ** System properties:
    OS=WindowsXP
    OS version=5.1
    Java version=1.6.0_03
    
    
    *** MyEclipse details:
    MyEclipse Enterprise Workbench
    Version: 6.0.1 GA
    Build id: 6.0.1-GA-200710
    
    
    *** Eclipse details:
    Eclipse SDK
    
    Version: 3.3.1.1
    Build id: M20071023-1652
    
    
    
    
    Eclipse Project SDK
    
    Version: 3.3.2.R33x_r20071022-7M7J7C_Mu2gop0b_GAwplOBhyuKO
    Build id: M20071023-1652
    
    
    Eclipse Plug-in Development Environment
    
    Version: 3.3.2.R33x_r20071022-7N7M4CYWLBCz-yHkMIuHN
    Build id: M20071023-1652
    
    
    Eclipse Platform
    
    Version: 3.3.2.R33x_v20071022-_19UEksF-G8Yc6bUv3Dz
    Build id: M20071023-1652
    
    
    Eclipse Graphical Editing Framework
    
    Version: 3.3.1.v20070814
    Build id: 20070814-1555
    
    
    Eclipse RCP
    
    Version: 3.3.2.R33x_r20071022-8y8eE9CEV3FspP8HJrY1M2dS
    Build id: M20071023-1652
    
    
    Eclipse Java Development Tools
    
    Version: 3.3.1.r331_v20070629-7o7jE72EDlXAbqAcnbmyg1rf8RIL
    Build id: M20071023-1652
    
    
    
    
    Eclipse startup command=-os
    win32
    -ws
    win32
    -arch
    x86
    -showsplash
    -launcher
    C:\Program Files\MyEclipse 6.0\eclipse.exe
    -name
    Eclipse
    --launcher.library
    C:\Program Files\MyEclipse 6.0\plugins\org.eclipse.equinox.launcher.win32.win32.x86_1.0.2.R331_v20071019\eclipse_1021.dll
    -startup
    C:\Program Files\MyEclipse 6.0\plugins\org.eclipse.equinox.launcher_1.0.1.R33x_v20070828.jar
    -exitdata
    85c_74
    -vm
    C:\jdk1.6.0_03\bin\javaw.exe
    
    

    and also Mac OS X:

    *** Date: 
    Wednesday, January 30, 2008 4:17:12 PM EST
    
    ** System properties:
    OS=MacOSX
    OS version=10.4.11
    Java version=1.5.0_13
    
    
    *** MyEclipse details:
    MyEclipse Enterprise Workbench
    Version: 6.0.1 GA
    Build id: 6.0.1-GA-200710
    
    
    *** Eclipse details:
    Eclipse SDK
    
    Version: 3.3.1.1
    Build id: M20071023-1652
    
    
    
    
    Eclipse Platform
    
    Version: 3.3.2.R33x_v20071022-_19UEksF-G8Yc6bUv3Dz
    Build id: M20071023-1652
    
    
    Eclipse Java Development Tools
    
    Version: 3.3.1.r331_v20070629-7o7jE72EDlXAbqAcnbmyg1rf8RIL
    Build id: M20070921-1145
    
    
    Eclipse Plug-in Development Environment
    
    Version: 3.3.2.R33x_r20071022-7N7M4CYWLBCz-yHkMIuHN
    Build id: M20070921-1145
    
    
    Eclipse Project SDK
    
    Version: 3.3.2.R33x_r20071022-7M7J7C_Mu2gop0b_GAwplOBhyuKO
    Build id: M20071023-1652
    
    
    Eclipse Graphical Editing Framework
    
    Version: 3.3.1.v20070814
    Build id: 20070814-1555
    
    
    Eclipse RCP
    
    Version: 3.3.2.R33x_r20071022-8y8eE9CEV3FspP8HJrY1M2dS
    Build id: M20070921-1145
    
    
    
    
    Eclipse startup command=-os
    macosx
    -ws
    carbon
    -arch
    x86
    -showsplash
    -launcher
    /Developer/Applications/MyEclipse 6.0/MyEclipse 6.0.app/Contents/MacOS/eclipse
    -name
    Eclipse
    --launcher.library
    /Developer/Applications/MyEclipse 6.0/MyEclipse 6.0.app/Contents/MacOS/../../../plugins/org.eclipse.equinox.launcher.carbon.macosx_1.0.2.R331_v20071019/eclipse_1021.so
    -startup
    /Developer/Applications/MyEclipse 6.0/MyEclipse 6.0.app/Contents/MacOS/../../../plugins/org.eclipse.equinox.launcher_1.0.1.R33x_v20070828.jar
    -keyring
    /Users/mattheie/.eclipse_keyring
    -consoleLog
    -showlocation
    -vm
    /System/Library/Frameworks/JavaVM.framework
    
    
    #281326 Reply

    Loyal Water
    Member

    Thanks for your help. I’ll try to get this fixed asap.

    #285078 Reply

    Any update on this issue?

    #285172 Reply

    Loyal Water
    Member

    IronDuck,
    Some other high priority items had to go into 6.5 that may cause this to get pushed out to the next release, sorry about that.

Viewing 8 posts - 1 through 8 (of 8 total)
Reply To: JPA Validator Ignores Inner Classes

You must be logged in to post in the forum log in