Enumerations in JPA

Hi all
I have a question about enumerations,
class Test{
   public enum Gender{
     Male, Female
@Enumerated(EnumType.STRING)
@Column(length=1)
private Gender gender;
}my question is this correct?
my goal is to keep only one character of the enumration
thanks for help

Hi guys,
here is what I did according to your suggestions
package com.entities;
import com.enumeration.Gender;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQuery;
@Entity
@NamedQuery(name="Employee.findAll", query="SELECT e FROM Employee e")
public class Employee implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Integer id;
    @Column(name="nom", length=30)
    private String nom;
    @Enumerated(EnumType.STRING)
    @Column(length=1)
    private Gender gender;
    public Integer getId() {
        return id;
    public void setId(Integer id) {
        this.id = id;
    public String getNom() {
        return nom;
    public void setNom(String nom) {
        this.nom = nom;
    public Gender getGender() {
        return gender;
    public void setGender(Gender gender) {
        this.gender = gender;
    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    @Override
    public boolean equals(Object object) {
        if (!(object instanceof Employee)) {
            return false;
        Employee other = (Employee) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        return true;
    @Override
    public String toString() {
        return "com.entities.Employee[ id=" + id + " ]";
package com.enumeration;
public enum Gender {
    M("Male"), F("Female");
    private String description;
    private Gender(String description) {
        this.description = description;
    public String getDescription() {
        return description;
}and it generates the table employee with the gender column as a varchar(1) witch is the desired result
thanks a million for help
best regards rashid

Similar Messages

  • JPA Enumerated annotation and EnumType.STRING

    Hi,
    There have been a few posts about @Enumeration within JPA.
    It seems that if you need to persist values other than the ordinal value
    of the enumeration that there is no use in @Enumeration as a JPA
    annotation.
    Say I have a Enumeration called Fruit.
    public enum Fruit{
    APPLE,
    ORANGE;
    I have a fruit VARCHAR2(1) column on a table and the constraint is that the value is in ('A', 'O') corresponding to the fruits.
    Firstly I annotate a field with @Enumerated(EnumType.String)
    Naively I looked at the J2SE 1.5 spec and saw I couldn't override the name() method on the enumeration but rather you are told to override toString().
    But Toplink Essentials doesn't use toString() to get the string value of the enumeration it uses????
    Is this an area which is addressed in JPA 2.0 or have missed the solution that is available in JPA 1.0 / Toplink Essentials.
    Peter.

    Peter,
    I ran into the same issue mapping TopLink's original Employee demo. We have a M->Male, F->Female object-type mapping that looked like an obvious candidate for the use of an enum. Unfortunately as you have experienced JPA does not support this.
    In Oracle TopLink 11gR1 and EclipseLink we have added annotations to expose our conversion mappings. With these custom annotations I can define a converter on any entity as:
    @ObjectTypeConverter(name = "gender", dataType = String.class, objectType = Gender.class, conversionValues = {
              @ConversionValue(dataValue = "M", objectValue = "Male"),
              @ConversionValue(dataValue = "F", objectValue = "Female") })Then when ever I want to use it I can simply annotate the field as:
         @Basic
         @Convert("gender")
         private Gender gender = Gender.Male;I believe these conversion mappings are also available in TopLink Essentials but you would need to configure the mapping using code in a descriptor-customizer.
    Doug

  • JPA:How to map List Map Enumerated,EntityType database?

    as we know that we can map collections to database with ElementCollection annotation; how to map a collection of collection of entity?
    for example:
    List<Map<Enumerated,EntityType>>
    thanks

    you have to do customization to acheive this.
    Check this Link
    Re: OIM: Manager Request access for subordinate

  • JPA - "no Metadata found for type" exception

    I use WebLogic 10 with Kodo as the JPA implementation. When attempting to query the DB for an entity, I get this very weird exception:
    org.apache.openjpa.persistence.ArgumentException: No metadata was found for type "class com.verid.ims.model.AddressUS". The class does not appear in the list of persistent types: [com.verid.ims.model.Birthdate, com.verid.ims.model.PersonName, com.verid.ims.model.AddressUS, com.rsa.idv.ims.feedback.IMSFeedback, com.rsa.idv.ims.notification.IMSNotification, com.rsa.idv.ims.provider.IMSProvider, com.rsa.idv.ims.notification.NotificationEntry, com.rsa.idv.ims.enroll.SecretUserQuestion, com.rsa.idv.ims.enroll.Enrollment].
    Please take into account that the AddressUS class, which according to the exception does not appear in the list of persistent types, is actually in the list! (Bold)
    The AddressUS class is mapped in my orm.xml file (it's not in the persistence.xml descriptor since it's not an entity, only an embeddable). Here is the mapping:
    <embeddable class="com.verid.ims.model.AddressUS">
    <attributes>
    <basic name="city" />
    <basic name="state">
    <enumerated>STRING</enumerated>
    </basic>
    <basic name="street1" />
    <basic name="street2" />
    <basic name="zipcode" />
    <basic name="suite" />
    </attributes>
    </embeddable>
    Needless to say, the persistence.xml descriptor refers to the orm.xml file.
    The exception only happens on some environments (not all of them), which basically means that it's an environmental problem. What could cause this?

    Thanks, that did help and it was throwing similar errors for other jar files, which I added and now the page opens.
    But the issue that I am facing now is on this page there is a Manager Search, wherein I can proxy a manager.
    This Search popup is not returning any values. Previously if I reinstalled my system-jazn-data.xml file from my colleauge
    and rebooting my laptop worked. But now even that doe snot help.
    Srinivasa Sunchu

  • JPA - Cannot Persist Detached Entity (Java EE 5)

    Hi All,
    I need your advice on identify what appears to be a persisting a detached School (ManyToMany) entity but could not understand why this is occurring:
    1.     The data supplied is made up of detail between counties and surrounding schools. There are a dozen of schools on average in any county. However, there
    will be some over-lapping schools that are a long the border of adjacent counties. For instance, county 1 consists of A, B, C, D, E, F, G, H, I, J, K, L schools while county 2
    (next to each other) is made up of M, N, B, O, P, Q, R, E, S, T, U, H schools. The common ones are B, E and H and are stored as duplicate records in the
    SCHOOL table.
    2.     
    3.     Lets look at the following code snippets on my attempt to come up with a solution without success still for quite sometime:  
    4.      
    5.     @Entity 
    6.     @IdClass(CountyPK.class)  
    7.     @Table(name="COUNTY", catalog="CountyDB", schema="")  
    8.     public class County implements Serializable {  
    9.           
    10.         @Id 
    11.         @Column(name="ZIPCODE")  
    12.         private String zipcode;  
    13.      
    14.         @Id 
    15.         @Column(name="COUNTY")  
    16.         private String county;  
    17.      
    18.         @Id 
    19.         @Enumerated(EnumType.STRING)  
    20.         @Column(name="STATE")  
    21.         @ManyToMany(cascade={CascadeType.PERSIST}, fetch=FetchType.EAGER)  
    22.         @JoinTable(name="COUNTY_SCHOOL", catalog="CountyDB", schema="",  
    23.                    joinColumns={@JoinColumn(name="ZIPCODE", referencedColumnName="ZIPCODE"),  
    24.                                 @JoinColumn(name="COUNTY", referencedColumnName="COUNTY"),  
    25.                                 @JoinColumn(name="STATE", referencedColumnName="STATE")},  
    26.                    inverseJoinColumns={@JoinColumn(name="SCHOOL", referencedColumnName="ID")})  
    27.         private Set<School>; schools = new HashSet<School>();  
    28.         public Set<School> getSchools()  
    29.         {  
    30.         return schools;  
    31.         }  
    32.         public void setSchools(Set<School> hotels)  
    33.         {  
    34.         this.schools = schools;  
    35.         }  
    36.     }  
    37.      
    38.     @Entity 
    39.     @Table(name="SCHOOL", catalog="CountyDB", schema="")  
    40.     public class School implements Serializable {  
    41.      
    42.         @Id 
    43.         @GeneratedValue(strategy = GenerationType.IDENTITY)  
    44.         @Column(name="ID")  
    45.         private int id;  
    46.      
    47.         @Column(name="SCHOOL_NAME")  
    48.         private String schoolName;  
    49.      
    50.         @ManyToMany(mappedBy="schools", cascade={CascadeType.ALL}, fetch=FetchType.EAGER)  
    51.         private Set<County> counties = new HashSet<County>();  
    52.         public Set<County> getCounties()  
    53.         {  
    54.         return counties;  
    55.         }  
    56.         public void setCounties(Set<County> counties)  
    57.         {  
    58.         this.counties = counties;  
    59.         }  
    60.      
    61.     @Stateless 
    62.     public class CountyBean implements CountyRemote {  
    63.           
    64.         @PersistenceContext(unitName="CountyDB-PU") private EntityManager manager;  
    65.           
    66.         public void createCounty(County county)  
    67.         {  
    68.             manager.persist(county);  
    69.             manager.flush();
    70.         }  
    71.      
    72.         public void saveOrUpdateCounty(County county)  
    73.         {  
    74.             manager.merge(county);
    75.             manager.flush();
    76.         }  
    77.      
    78.      
    79.         public County findCounty(String zipcode, String county, State state)  
    80.         {  
    81.             CountyPK pk = new CountyPK(zipcode, county, state);  
    82.             return manager.find(County.class, pk);  
    83.         }  
    84.           
    85.         public List fetchCountiesWithRelationships()  
    86.         {  
    87.           List list = manager.createQuery("SELECT DISTINCT c FROM County c LEFT JOIN FETCH c.counties").getResultList();  
    88.           for (Object obj : list)  
    89.           {  
    90.              County county = (County)obj;  
    91.           }  
    92.           return list;  
    93.        }  
    94.      
    95.     @Stateless 
    96.     public class SchoolBean implements SchoolRemote {  
    97.           
    98.         @PersistenceContext(unitName="CountyDB-PU") private EntityManager manager;  
    99.           
    100.         public void createSchool(School school)  
    101.         {  
    102.             manager.persist(school);  
    103.         }  
    104.      
    105.         public void saveOrUpdateSchool(School school)  
    106.         {  
    107.             manager.merge(school);  
    108.         }  
    109.      
    110.         public School findSchool(int school_id)  
    111.         {  
    112.             return manager.find(School.class, school_id);  
    113.         }  
    114.      
    115.         public School findSchool(String schoolName)  
    116.         {  
    117.             School school = null;
    118.             Query query = manager.createQuery("Select s FROM School s where s.schoolName = :schoolName");
    119.             query.setParameter("schoolName", schoolName);
    120.             List list = query.getResultList();
    121.             for (Object obj : list)
    122.             {
    123.                 school = (School)obj;
    124.                 if (school.getSchoolName().matches(schoolName))
    125.                     return school;
    126.             }
    127.             return school;   
    128.         }  
    129.                 
    130.         public List fetchSchoolsWithRelationships()  
    131.         {  
    132.              List list = manager.createQuery("SELECT DISTINCT s FROM School s LEFT JOIN FETCH s.schools").getResultList();  
    133.              for (Object obj : list)  
    134.              {  
    135.                  School school = (School)obj;  
    136.              }  
    137.              return list;  
    138.         }  
    139.     }  
    140.      
    141.     public class ApplicationClientAddCounty {  
    142.      
    143.         @EJB 
    144.         private static CountyRemote remoteCountybean;  
    145.         @EJB 
    146.         private static SchoolRemote remoteSchoolbean;  
    147.      
    148.         public static void main(String[] args)
    149.         {  
    150.             BufferedReader br = new BufferedReader(new FileReader("COUNTY.XML"));   
    151.             while (countyList_iterator.hasNext())  
    152.             {  
    153.                 County county = new County();  
    154.                 county.setZipcode(((org.jdom.Element)countyList_iterator.next()).getChild("zipcode");  
    155.                 while (schoolList_iterator.hasNext())  
    156.                 {  
    157.                     String school_name = ((org.jdom.Content)schoolsList_iterator.next()).getValue();  
    158.                     if (school_name.length() != 0)  
    159.                     {  
    160.                          School school = null;  
    161.                          if (!school_name.contains("Schools:"))  
    162.                          {  
    163.                               school = remoteSchoolbean.findSchool(school_name);
    164.                               if (school == null)
    165.                               {
    166.                                   school = new School();
    167.                                   school.setSchoolName(school_name);
    168.                               }
    169.                               county.getSchools().add(school);  
    170.                           }  
    171.                      }
    172.                 }  
    173.            }  
    174.            remoteCountybean.createCounty(county);
    175.     } Below is the a simplistic set of the data available which resulted in deplicate School records being persisted:
    COUNTY
    ID     Name
    1     County 1
    2     County 2
    COUNTY_SCHOOL
    ID     COUNTY_ID     SCHOOL_ID
    1     County 2     1
    2     County 1     2
       SCHOOL
    ID     Name
    1     School A
    2     School A
    Yet I wanted only a single normalized School to be generated instead:
    COUNTY
    ID     Name
    1     County 1
    2     County 2
    COUNTY_SCHOOL
    ID     COUNTY_ID     SCHOOL_ID
    1     County 1     1
    2     County 2     1
       SCHOOL
    ID     Name
    1     School A    I am not clear on why the following behavior is taking place within JPA:
    ( i ) The ID for County 1 in COUNTY_SCHOOL is 2 instead of 1. Vice versa for County 2.
    ( ii ) More importantly, why is School A being populated twice even though the data is identical.
    There appears to be some transactional issue/delay using the container managed JTA. Another intriguing symptom is that the following exception occurred after having taken out the @GeneratedValue(strategy = GenerationType.IDENTITY) in School.java in the hope that only a single record is generated:
    *EJB5018: An exception was thrown during an ejb invocation on [CountyBean]*
    javax.ejb.TransactionRolledbackLocalException: Exception thrown from bean; nested exception is: javax.persistence.EntityExistsException:
    *Exception Description: Cannot persist detached object [domain.School@ce9fa6].*
    Class> domain.School Primary Key> [0]
    javax.persistence.EntityExistsException:
    *Exception Description: Cannot persist detached object [domain.School@ce9fa6].*
    Class> domain.School Primary Key> [0]
    at oracle.toplink.essentials.internal.ejb.cmp3.base.EntityManagerImpl.persist(EntityManagerImpl.java:224)
    at com.sun.enterprise.util.EntityManagerWrapper.persist(EntityManagerWrapper.java:440)
    at ejb.CountyBean.createCounty(CountyBean.java:18)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    oracle.toplink.essentials.exceptions.ValidationException
    *... 38 more*
    On the other hand, another database exception occurred when directly persisting County & School using remoteCountybean.createCounty(county) as opposed to sending it through a message queue with sendJMSMessageToMyQueue(county) which works:
    *02/02/2011 5:22:14 PM com.sun.enterprise.appclient.MainWithModuleSupport <init>*
    WARNING: ACC003: Application threw an exception.
    javax.ejb.EJBException: nested exception is: java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
    java.rmi.RemoteException: null; nested exception is:
    javax.persistence.EntityExistsException:
    *Exception Description: Cannot persist detached object [domain.School@1fcea34].*
    Class> domain.School Primary Key> [1]
    Caused by: javax.ejb.EJBException: nested exception is: java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
    java.rmi.RemoteException: null; nested exception is:
    javax.persistence.EntityExistsException:
    *Exception Description: Cannot persist detached object [domain.School@1fcea34].*
    Class> domain.School Primary Key> [1]
    at ejb._CountyRemote_Wrapper.createCounty(ejb/_CountyRemote_Wrapper.java)
    at addCounty(localImportCounty.java:296)I am running JDK1.6.0_17, GF 2.1 on XP. This is a Java EE 5 Enterprise Application.
    It would be much appreciated for some guidance in an unfamiliar territory. I have had many attempts and read up quite a number of similar threats
    But none offer concrete results.
    Thanks in advance,
    Jack

    Hi,
    A minor correction of the last statement in ApplicationClientAddCounty class below:
    141.     public class ApplicationClientAddCounty {  
    142.      
    143.         @EJB 
    144.         private static CountyRemote remoteCountybean;  
    145.         @EJB 
    146.         private static SchoolRemote remoteSchoolbean;  
    147.      
    148.         public static void main(String[] args)
    149.         {  
    150.             BufferedReader br = new BufferedReader(new FileReader("COUNTY.XML"));   
    151.             while (countyList_iterator.hasNext())  
    152.             {  
    153.                 County county = new County();  
    154.                 county.setZipcode(((org.jdom.Element)countyList_iterator.next()).getChild("zipcode");  
    155.                 while (schoolList_iterator.hasNext())  
    156.                 {  
    157.                     String school_name = ((org.jdom.Content)schoolsList_iterator.next()).getValue();  
    158.                     if (school_name.length() != 0)  
    159.                     {  
    160.                          School school = null;  
    161.                          if (!school_name.contains("Schools:"))  
    162.                          {  
    163.                               school = remoteSchoolbean.findSchool(school_name);
    164.                               if (school == null)
    165.                               {
    166.                                   school = new School();
    167.                                   school.setSchoolName(school_name);
    168.                               }
    169.                               county.getSchools().add(school);  
    170.                           }  
    171.                      }
    172.                 }
    173.                remoteCountybean.createCounty(county);
    173.            }  
    174.     } Thanks,
    Jack

  • JPA - Interface Entity

    Hi,
    I am looking for help to create an class hierarchy that would use interface instead inheritance.
    My example: In a house I have livingrooms, kitchens, and bedrooms. So I have a class for each type of room, and theses classes extends Contruction (another entity).
    I also have furniture. I would like to retrieve all the rooms that have a funiture type.
    See below (simple version):
    @Entity
    class Construction {
    @Id
    private Long id
    @Entity
    class LivingRoom extends Construction implements Equipable {
    @ManyToMany
    List<Funiture> furnitures
    @Entity
    class Furniture {
    @ManyToMany
    List<Equipable> equipables
    }Is it possible to map that with JPA? My final objective is to retrieve a List of Places that a forniture could be, and also alll the forniture that a place could have.
    I am trying that with jpa/hibernate but I am not having any success.
    And, if it is not possible, the best way to implement that?
    Thx

    Unfortunately you cannot do this. From the persistence section of the JavaEE 5 Tutorial:
    The persistent state of an entity can be accessed either through the entity�s
    instance variables or through JavaBeans-style properties. The fields or properties
    must be of the following Java language types:
    � Java primitive types
    � java.lang.String
    � Other serializable types including:
    � Wrappers of Java primitive types
    � java.math.BigInteger
    � java.math.BigDecimal
    � java.util.Date
    � java.util.Calendar
    � java.sql.Date
    � java.sql.Time
    � java.sql.TimeStamp
    � User-defined serializable types
    � byte[]
    � Byte[]
    � char[]
    � Character[]
    � Enumerated types
    � Other entities and/or collections of entities
    � Embeddable classes
    As you can see this doesn't mention interfaces, which makes sense since they are abstract and have no actual state to persist - the best way I've thought of to cope would be to have everything you want to implement 'equipable' inherit from a parent class, even if that class is completely anemic.
    If anyone has any better solutions please reply.

  • Error in allocating a connection + JPA

    Hello Experts,
    I am trying my first ever JPA Program.I am using netbeans 6.0.In netbeans there is a sample application for WebJPA.In that they are calling entity from servlet.I just made a different project.I have copied all files in my project.At the time of creating persistence unit I have used DB2.But now when I am compiling my project I am getting the following errors.Seems there is some problem with connection to DB2.I have also added the correct jar files during creation of persistence unit.Please help me.Many Thanx in advance.
    *Deploying application in domain failed; Deployment Errorjava.sql.SQLException: Error in allocating a connection. Cause: Connection could not be allocated because: Failure in loading T2 native library db2jcct2, reason: java.lang.UnsatisfiedLinkError: no db2jcct2 in java.library.path --*
    Internal Exception: java.sql.SQLException: Error in allocating a connection. Cause: Connection could not be allocated because: Failure in loading T2 native library db2jcct2, reason: java.lang.UnsatisfiedLinkError: no db2jcct2 in java.library.path
    Error Code: 0
    Deployment error:
    The module has not been deployed.
    See the server log for details.
    at org.netbeans.modules.j2ee.deployment.devmodules.api.Deployment.deploy(Deployment.java:163)
    at org.netbeans.modules.j2ee.ant.Deploy.execute(Deploy.java:104)
    at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
    at sun.reflect.GeneratedMethodAccessor1068.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:105)
    at org.apache.tools.ant.Task.perform(Task.java:348)
    at org.apache.tools.ant.Target.execute(Target.java:357)
    at org.apache.tools.ant.Target.performTasks(Target.java:385)
    at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1329)
    at org.apache.tools.ant.Project.executeTarget(Project.java:1298)
    at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
    at org.apache.tools.ant.Project.executeTargets(Project.java:1181)
    at org.apache.tools.ant.module.bridge.impl.BridgeImpl.run(BridgeImpl.java:277)
    at org.apache.tools.ant.module.run.TargetExecutor.run(TargetExecutor.java:460)
    at org.netbeans.core.execution.RunClassThread.run(RunClassThread.java:151)
    Caused by: The module has not been deployed.
    at org.netbeans.modules.j2ee.deployment.devmodules.api.Deployment.deploy(Deployment.java:157)

    Hi garava,
    Thanks for the reply.I had followed the same path while creating Persistence Unit.I googled this error & I found a solution where I need to set the NativeLibraryPathPrefix in my JVM.
    For this I went to Servers->Glassfish V2 -> JVM-> .There I set NativeLibraryPathPrefix = D:\Program Files\IBM\SQLLIB\BIN.
    It's working now.But I can't understand what was the problem & how it got solved.
    One more issue ,suppose tom I am facing the same problem for some other XYZ database.Do I need to change this path again for that database.What this path exactly means.I read it looks for "db2jcc2.dll" in this path.What is the need of this dll if I am including jar files during creation of persistence Unit.
    Please help.Thanks in advance.

  • How to check the table existence in JPA

    1) is there a way I can check for existence of the table using JPA, before I read the rows.
    2) If I want to create two tables with same columns (name, time), Should I create two entity objects to insert? is there a way to use one enity class and specify a table to insert ?
    thanks
    Vamshi

    Try this:
    function findNodes(vNode){
         if (vNode.className === "field"){
              if (vNode.isPropertySpecified("name")===true){
                   var myStateName=new RegExp(vNode.name);
                   var returnValue = GFL.search(myStateName);
                   if (returnValue!=-1){
                        this.ui.oneOfChild.border.fill.color.value="192,192,192";
                        this.access="readOnly";
                   else{  
                        this.ui.oneOfChild.border.fill.color.value="255,255,255";//whatever colour is open access
                        this.access="open";
         for (var a=0;a<vNode.nodes.length;a++){
              findNodes(vNode.nodes.item(a));
    findNodes(xfa.form);
    Kyle

  • Problems with enumerated type and DataSocket

    I am publishing an enumerated type variable using DataSocket write and I am having problems subscribing to this with other clients on the network. I can get the program to work ok if I replace the enumerated type with a straight numeric or a Text Ring for example. Is there anything special I should be looking out for when using enumerated types in this type of application.
    Thanks Kelly

    Updating to the latest version of LabVIEw (6.0.2) should correct this problem:
    http://digital.ni.com/softlib.nsf/websearch/F983BDA17B8F401B862569EC005A11C2
    Also, I would suggest updating to the latest version DataSocket:
    http://digital.ni.com/softlib.nsf/web%2Fall%20software?OpenView&Start=1&Count=500&Expand=6#6
    Chris_Mitchell
    Product Development Engineer
    Certified LabVIEW Architect

  • Unable to deploy Web App using JPA TopLink Essentials in Tomcat5.5.17

    Hi All,
    I am trying to deploy a Web App ( used Top Link Essentials ) to Tomcat and i am getting the following Error..
    I am strating tomcat using -javaagent:/Path/To/spring-agaent.jar
    Dec 14, 2006 9:52:46 AM org.apache.catalina.loader.WebappClassLoader loadClass
    INFO: Illegal access: this web application instance has been stopped already.  Could not load oracle.toplink.essentials.internal.weaving.ClassDetails.  The eventual following stack trace is caused by an error thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access, and has no functional impact.
    java.lang.IllegalStateException
            at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1238)
            at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1198)
            at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
            at oracle.toplink.essentials.internal.weaving.TopLinkWeaver.transform(TopLinkWeaver.java:84)
            at org.springframework.orm.jpa.persistenceunit.ClassFileTransformerAdapter.transform(ClassFileTransformerAdapter.java:56)
            at sun.instrument.TransformerManager.transform(TransformerManager.java:122)
            at sun.instrument.InstrumentationImpl.transform(InstrumentationImpl.java:155)
            at java.lang.ClassLoader.defineClass1(Native Method)
            at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
            at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
            at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:1812)
            at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:866)
            at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1319)
            at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1198)
            at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
            at java.lang.Class.getDeclaredConstructors0(Native Method)
            at java.lang.Class.privateGetDeclaredConstructors(Class.java:2357)
            at java.lang.Class.getConstructor0(Class.java:2671)
            at java.lang.Class.newInstance0(Class.java:321)
            at java.lang.Class.newInstance(Class.java:303)
            at org.apache.myfaces.application.ApplicationImpl.createComponent(ApplicationImpl.java:396)
            at com.sun.faces.config.ConfigureListener.verifyObjects(ConfigureListener.java:1438)
            at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:509)
            at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3729)
            at org.apache.catalina.core.StandardContext.start(StandardContext.java:4187)
            at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:759)
            at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:739)
            at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:524)
            at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:608)
            at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:535)
            at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:470)
            at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1122)
            at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:310)
            at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
            at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1021)
            at org.apache.catalina.core.StandardHost.start(StandardHost.java:718)
            at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1013)
            at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:442)
            at org.apache.catalina.core.StandardService.start(StandardService.java:450)
            at org.apache.catalina.core.StandardServer.start(StandardServer.java:709)
            at org.apache.catalina.startup.Catalina.start(Catalina.java:551)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
            at java.lang.reflect.Method.invoke(Method.java:585)
            at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:294)
            at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:432) Thanks
    Sateesh

    Spring 2.0 provides custom support for TopLink Essentials in Tomcat out-of-the-box. You should follow the instructions here: http://static.springframework.org/spring/docs/2.0.x/reference/orm.html#orm-jpa-setup-lcemfb-tomcat
    Essentially, Spring provides a custom class loader for Tomcat and doesn't use an agent.
    --Shaun                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Null value in List Binding (enumeration mode)

    Hi,
    how can I declare a NULL value in a List binding with enumeration mode?
    A user should be able to select an empty entry in a combobox to update an attribute with a null value.
    I'm using JDev9052 and JClient.
    Any hints?
    Thanks,
    Markus

    Adding '-1' in JComboBox (addItem(new Integer(-1))) or in the control binding does not change the picture. Sorry.
    While play with different List bindings I have discovered that a Button LOV Binding works when using a "select * UNION select null from dual" view object. It does not work with a Combobox LOV binding. Why?
    Still, my problem List binding in enumeration mode (with Combobox) is unsolved. any hints or samples?
    My current combobox binding:
    <DCControl
    id="Job"
    DefClass="oracle.jbo.uicli.jui.JUComboBoxDef"
    SubType="DCComboBox"
    BindingClass="oracle.jbo.uicli.jui.JUComboBoxBinding"
    IterBinding="EmpView1Iterator"
    ApplyValidation="false"
    isDynamic="false"
    ListOperMode="0"
    StaticList="true"
    Editable="false" >
    <AttrNames>
    <Item Value="Job" />
    </AttrNames>
    <ValueList>
    <Item Value="ANALYST" />
    <Item Value="CLERK" />
    <Item Value="MANAGER" />
    <Item Value="PRESIDENT" />
    <Item Value="SALESMAN" />
    <Item Value="-1" />
    </ValueList>
    </DCControl>
    My current Button LOV binding:
    <DCControl
    id="Job2"
    DefClass="oracle.jbo.uicli.jui.JULovButtonDef"
    SubType="DCLovButton"
    BindingClass="oracle.jbo.uicli.jui.JULovButtonBinding"
    IterBinding="EmpView1Iterator"
    DTClass="oracle.adf.dt.objects.JUDTCtrlListLOV"
    ApplyValidation="false"
    isDynamic="false"
    ListOperMode="0"
    ListIter="JobListView1Iterator" >
    <AttrNames>
    <Item Value="Job" />
    </AttrNames>
    <ListAttrNames>
    <Item Value="Job" />
    </ListAttrNames>
    <ListDisplayAttrNames>
    <Item Value="Job" />
    </ListDisplayAttrNames>
    </DCControl>

  • More fun with enumerated dropdowns - Binding to table

    Hi All,
    I'm having some trouble with enumerated dropdowns.
    My context is as follows:
    node DATA 1...1
    ---> node FLIGHTS 0...N
       -->CARRID etc from SFLIGHTS
    --->DDL (element type string)
    I have successfully tried to add a simple dropdown with the following code on the component controller:
    method wddoinit .
        data lo_nd_data type ref to if_wd_context_node.
        data lo_el_data type ref to if_wd_context_element.
        data ls_data type wd_this->element_data.
        data lv_ddl like ls_data-ddl.
        data node_info type ref to if_wd_context_node_info.
        data vals type table of  wdr_context_attr_value.
        data: s_element type wdr_context_attr_value.
        data: str type string.
    *   navigate from <CONTEXT> to <DATA> via lead selection
        lo_nd_data = wd_context->get_child_node( name = wd_this->wdctx_data ).
    *   get element via lead selection
        lo_el_data = lo_nd_data->get_element(  ).
        lo_el_data->get_static_attributes(
          importing
            static_attributes = ls_data ).
    *      get node info
        call method lo_nd_data->get_node_info
          receiving
            node_info = node_info.
         do 25 times.
           str = sy-index.
           condense str no-gaps.
           s_element-text = str.
           s_element-value = str.
           append s_element to vals.
        enddo.
    *    Set Value_sets to node_info
         call method node_info->set_attribute_value_set
          exporting
            name      = 'DDL'
            value_set = vals
    endmethod.
    This works fine, however now I am trying the same thing with a field from the SFLIGHTS table.
    I want to display a table of the retrieved SFLIGHTS but a field as a dropdown with valid entries from the database. I have added the following code to the view.
    method WDDOINIT .
        data lo_nd_data type ref to if_wd_context_node.
        data lo_nd_flights type ref to if_wd_context_node.
        data lo_el_flights type ref to if_wd_context_element.
        data ls_flights type wd_this->element_flights.
        data gt_flights type table of sflights.
        select * from sflights into table gt_flights.
    *   navigate from <CONTEXT> to <DATA> via lead selection
        lo_nd_data = wd_context->get_child_node( name = wd_this->wdctx_data ).
    *   navigate from <DATA> to <FLIGHTS> via lead selection
        lo_nd_flights = lo_nd_data->get_child_node( name = wd_this->wdctx_flights ).
        lo_nd_flights->bind_table( gt_flights ).
           types: begin of ty_carrname,
         carrname type s_carrname,
         end of ty_carrname.
       data: gt_carrname type table of ty_carrname.
       select distinct carrname
          from sflights
          into table gt_carrname.
         data lv_carrname like ls_flights-carrname.
         data node_info type ref to if_wd_context_node_info.
         data vals type table of  wdr_context_attr_value.
         data: s_element type wdr_context_attr_value.
         data: str type string.
          lo_nd_flights->get_static_attributes(
          importing
            static_attributes = ls_flights ).
          call method lo_nd_flights->get_node_info
          receiving
            node_info = node_info.
         field-symbols: <carrname> like line of gt_carrname.
         loop at gt_carrname assigning <carrname>.
           str = <carrname>-carrname.
           s_element-text = str.
           s_element-value = str.
           append s_element to vals.
         endloop.
         call method node_info->set_attribute_value_set
          exporting
            name      = 'CARRNAME'
            value_set = vals.
    endmethod.
    I can display all the entries with a repeating subform but when I bind the CARRNAME to an enumerated dropdown I get an ADS rendering error:
    WebDynpro Exception: The ADS call has failed. You can find information about the cause in the error.pdf on the application server
    I have looked in the Error PDF but it is blank.
    Does anyone have any suggestions on what is goign wrong or how to diagnose the problem.
    I am assuming you can have a data element that has a 0..N cardinality (i.e a table element) and is also of type enumerated dropdown.
    I'm guessing this is something to do with cardinality but I have no way to find out.
    Thanks,
    Gregor

    I have looked in the defaultTrace file and found the following errors:
    1.  A pdf document with 0 pages.
        Return Status: Render Failure
        Output Trace returned: <?xml version="1.0" encoding="UTF-8"?>
    <log>
       <m mid="29184" tid="10064.4896" sev="f" d="2008-11-12T15:20:01.722Z">Malformed SOM expression: $record.sap-vhlist.FLIGHTS\\.DATA[*]\\.CARRNAME.item[*]</m></log>
    Has anybody else used the enumerated dropdown element bound to dynamic data?
    I am using the latest releases and the "Specify Item Values" on the Object->Binding tab is filled in with what looks correct ($record.sap-vhlist.FLIGHTS\.Data etc) but greyed out.
    Thanks

  • How to read enumerated values from an OPC server via Datasocket

    Hi Labviewers,
    I am using LV8.2 and I am trying to find if it is possible to read enumerations from an OPC server via Datasocket, not just the values.
    I can successfully read a value for an OPC server via Datasocket and I get a value for example 3, is it possible to get the enumeration/string that corresponds to this value i.e. "Open".
    Many thanks in advance
    Dimitris

    Hi Sarah,
    With the input type as variant I get the following response:
    1                                     <-This is the current numeric value of the parameter
    4 Attribute(s):
       'Quality' -> 192
       'TimeHigh' -> 29861723
       'TimeLow' -> -665408304
       'Timestamp' -> 39.238E+3
    With the Input set to         Enum constant I get no values or strings coming back. With the Input set to                Ring constant I just get the numeric value   
    Dimitris   

  • How to create a cache for JPA Entities using an EJB

    Hello everybody! I have recently got started with JPA 2.0 (I use eclipseLink) and EJB 3.1 and have a problem to figure out how to best implement a cache for my JPA Entities using an EJB.
    In the following I try to describe my problem.. I know it is a bit verbose, but hope somebody will help me.. (I highlighted in bold the core of my problem, in case you want to first decide if you can/want help and in the case spend another couple of minutes to understand the domain)
    I have the following JPA Entities:
    @Entity Genre{
    private String name;
    @OneToMany(mappedBy = "genre", cascade={CascadeType.MERGE, CascadeType.PERSIST})
    private Collection<Novel> novels;
    @Entity
    class Novel{
    @ManyToOne(cascade={CascadeType.MERGE, CascadeType.PERSIST})
    private Genre genre;
    private String titleUnique;
    @OneToMany(mappedBy="novel", cascade={CascadeType.MERGE, CascadeType.PERSIST})
    private Collection<NovelEdition> editions;
    @Entity
    class NovelEdition{
    private String publisherNameUnique;
    private String year;
    @ManyToOne(optional=false, cascade={CascadeType.PERSIST, CascadeType.MERGE})
    private Novel novel;
    @ManyToOne(optional=false, cascade={CascadeType.MERGE, CascadeType.PERSIST})
    private Catalog appearsInCatalog;
    @Entity
    class Catalog{
    private String name;
    @OneToMany(mappedBy = "appearsInCatalog", cascade = {CascadeType.MERGE, CascadeType.PERSIST})
    private Collection<NovelEdition> novelsInCatalog;
    The idea is to have several Novels, belonging each to a specific Genre, for which can exist more than an edition (different publisher, year, etc). For semplicity a NovelEdition can belong to just one Catalog, being such a Catalog represented by such a text file:
    FILE 1:
    Catalog: Name Of Catalog 1
    "Title of Novel 1", "Genre1 name","Publisher1 Name", 2009
    "Title of Novel 2", "Genre1 name","Pulisher2 Name", 2010
    FILE 2:
    Catalog: Name Of Catalog 2
    "Title of Novel 1", "Genre1 name","Publisher2 Name", 2011
    "Title of Novel 2", "Genre1 name","Pulisher1 Name", 2011
    Each entity has associated a Stateless EJB that acts as a DAO, using a Transaction Scoped EntityManager. For example:
    @Stateless
    public class NovelDAO extends AbstractDAO<Novel> {
    @PersistenceContext(unitName = "XXX")
    private EntityManager em;
    protected EntityManager getEntityManager() {
    return em;
    public NovelDAO() {
    super(Novel.class);
    //NovelDAO Specific methods
    I am interested at when the catalog files are parsed and the corresponding entities are built (I usually read a whole batch of Catalogs at a time).
    Being the parsing a String-driven procedure, I don't want to repeat actions like novelDAO.getByName("Title of Novel 1") so I would like to use a centralized cache for mappings of type String-Identifier->Entity object.
    Currently I use +3 Objects+:
    1) The file parser, which does something like:
    final CatalogBuilder catalogBuilder = //JNDI Lookup
    //for each file:
    String catalogName = parseCatalogName(file);
    catalogBuilder.setCatalogName(catalogName);
    //For each novel edition
    String title= parseNovelTitle();
    String genre= parseGenre();
    catalogBuilder.addNovelEdition(title, genre, publisher, year);
    //End foreach
    catalogBuilder.build();
    2) The CatalogBuilder is a Stateful EJB which uses the Cache and gets re-initialized every time a new Catalog file is parsed and gets "removed" after a catalog is persisted.
    @Stateful
    public class CatalogBuilder {
    @PersistenceContext(unitName = "XXX", type = PersistenceContextType.EXTENDED)
    private EntityManager em;
    @EJB
    private Cache cache;
    private Catalog catalog;
    @PostConstruct
    public void initialize() {
    catalog = new Catalog();
    catalog.setNovelsInCatalog(new ArrayList<NovelEdition>());
    public void addNovelEdition(String title, String genreStr, String publisher, String year){
    Genre genre = cache.findGenreCreateIfAbsent(genreStr);//##
    Novel novel = cache.findNovelCreateIfAbsent(title, genre);//##
    NovelEdition novEd = new NovelEdition();
    novEd.setNovel(novel);
    //novEd.set publisher year catalog
    catalog.getNovelsInCatalog().add();
    public void setCatalogName(String name) {
    catalog.setName(name);
    @Remove
    public void build(){
    em.merge(catalog);
    3) Finally, the problematic bean: Cache. For CatalogBuilder I used an EXTENDED persistence context (which I need as the Parser executes several succesive transactions) together with a Stateful EJB; but in this case I am not really sure what I need. In fact, the cache:
    Should stay in memory until the parser is finished with its job, but not longer (should not be a singleton) as the parsing is just a very particular activity which happens rarely.
    Should keep all of the entities in context, and should return managed entities form mehtods marked with ##, otherwise the attempt to persist the catalog should fail (duplicated INSERTs)..
    Should use the same persistence context as the CatalogBuilder.
    What I have now is :
    @Stateful
    public class Cache {
    @PersistenceContext(unitName = "XXX", type = PersistenceContextType.EXTENDED)
    private EntityManager em;
    @EJB
    private sessionbean.GenreDAO genreDAO;
    //DAOs for other cached entities
    Map<String, Genre> genreName2Object=new TreeMap<String, Genre>();
    @PostConstruct
    public void initialize(){
    for (Genre g: genreDAO.findAll()) {
    genreName2Object.put(g.getName(), em.merge(g));
    public Genre findGenreCreateIfAbsent(String genreName){
    if (genreName2Object.containsKey(genreName){
    return genreName2Object.get(genreName);
    Genre g = new Genre();
    g.setName();
    g.setNovels(new ArrayList<Novel>());
    genreDAO.persist(t);
    genreName2Object.put(t.getIdentifier(), em.merge(t));
    return t;
    But honestly I couldn't find a solution which satisfies these 3 points at the same time. For example, using another stateful bean with an extended persistence context (PC) would work for the 1st parsed file, but I have no idea what should happen from the 2nd file on.. Indeed, for the 1st file the PC will be created and propagated from CatalogBuilder to Cache, which will then use the same PC. But after build() returns, the PC of CatalogBuilder should (I guess) be removed and re-created during the succesive parsing, although the PC of Cache should stay "alive": shouldn't in this case an exception being thrown? Another problem is what to do when the Cache bean is passivated. Currently I get the exception:
    "passivateEJB(), Exception caught ->
    java.io.IOException: java.io.IOException
    at com.sun.ejb.base.io.IOUtils.serializeObject(IOUtils.java:101)
    at com.sun.ejb.containers.util.cache.LruSessionCache.saveStateToStore(LruSessionCache.java:501)"
    Hence, I have no Idea how to implement my cache.. Can you please tell me how would you solve the problem?
    Many thanks!
    Bye

    Hi Chris,
    thanks for your reply!
    I've tried to add the following into persistence.xml (although I've read that eclipseLink uses L2 cache by default..):
    <shared-cache-mode>ALL</shared-cache-mode>
    Then I replaced the Cache bean with a stateless bean which has methods like
    Genre findGenreCreateIfAbsent(String genreName){
    Genre genre = genreDAO.findByName(genreName);
    if (genre!=null){
    return genre;
    genre = //Build new genre object
    genreDAO.persist(genre);
    return genre;
    As far as I undestood, the shared cache should automatically store the genre and avoid querying the DB multiple times for the same genre, but unfortunately this is not the case: if I use a FINE logging level, I see really a lot of SELECT queries, which I didn't see with my "home made" Cache...
    I am really confused.. :(
    Thanks again for helping + bye

  • Help with exporting document and generating an enumerated value error

    Can anyone help me figure out why I cannot get this script to export the document and save it for the web?
    I keep getting the same frustrating "Enumerated Value expected".
    here is the script thus far:
    * attempting to create a script to insert names automatically within photoshop cs2. Similar to the PSP.
    tag = app.activeDocument;
    var lee = ["Barb","Belle","Betty","Carmel","Christy","Connie",
    "Debbie","Debra","Denise","Diamond","Dolceluna","Irene","Jacqui"];
    //determine if active layer is a text layer or not.
    if(tag.isBackground == true){
    alert("this is a background layer and cannot be changed.");
    else{
    alert("this is the name layer.")
    for(i=0;i<lee.length;i++){
    tag.activeLayer.textItem.contents = lee[i];
    var options = new ExportOptionsSaveForWeb();
    options.format = SaveDocumentType.PNG-24;
    options.interlaced = false;
        options.PNG8= false;
    var fName = lee[i];
    var newName = fName+'-'+tag.name+'.png';
    alert(newName);
    //EXPORT DOCUMENT KEEPS GENERATING ENUMBERATED VALUE EXPECTED
    // web.matte = MatteType.NONE;
    tag.exportDocument(File(tag.path + '/' + newName),ExportType.SAVEFORWEB,options);
    } // closes for loop
    }// end of else statement

    Yes the guide is misleading. It says 'For this property, only COMPUSERVEGIF, JPEG, PNG-8, PNG-24, and BMP are supported.'
    It really should say 'For this property, only COMPUSERVEGIF, JPEG, PNG, and BMP are supported.'
    But if you look under SaveDocumentType you will not find PNG-8 or PNG-24 listed in the values.

Maybe you are looking for

  • Rename file in a portfolio

    In an acrobat 9 pro portfolio, when I attempt to rename a file  I get the message "this file is locked" This issue only appeared after I installed Adobe Acrobat Pro on a new computer. I did not have this issue on the previous installation

  • Performance tuning Issue

    Hi folks, I having a problem with performance tuning ... Below is a sample query SELECT /*+ PARALLEL (K 4) */ DISTINCT ltrim(rtrim(ibc_item)), substr(IBC_BUSINESS_CLASS, 1,1) FROM AAA K WHERE ltrim(rtrim(ibc_item)) NOT IN select /*+ PARALLEL (II 4) *

  • Problem with importing my package in JSP

    This is the code for creating a package dbconnection: package dbconnection; import java.sql.*; public class DBConnection      java.sql.Connection con=null;      public void DBConnection(){ }      public java.sql.Connection getDBConnection() try{     

  • How to do Delta upload and consolidate in SSM, how to use transformer.ini

    Hi, Can anybody explain me how to do Delta data upload and also how to do delta data consolidation in SAP SSM. Also how can i create and use transformer.ini file. Thanks and reagrds Edited by: Himanshu Bisla on Mar 25, 2009 2:09 PM

  • Final Cut Pro 7 Serial Number does not work

    After the latest Apple Update my FCP program puts up a requestor box wanting the serial number. When I put the number in the box says Incorrect. I've tried everything like changing 0 to O to copy and pasting and keying in. Nothing works. What did App