0 Replies Latest reply on Jul 26, 2006 1:43 PM by gup123

    facing issues in persisting standalone application using hib

    gup123

      Hi I am new to this area and I am using hibernate3.2, hibernate-annotation3.2 and hibernate-entitymanager3.2 for persisting a object in the database in a standalone program i.e. plain java, but i am getting the following program when i run.

      Please suggest any solution or if i am missing anything: exception is =:

      [java] Exception in thread "main" java.lang.IllegalAccessError: tried to access method net.s
      f.ehcache.CacheManager.()V from class org.hibernate.cache.EhCacheProvider
      [java] at org.hibernate.cache.EhCacheProvider.start(EhCacheProvider.java:124)
      [java] at org.hibernate.impl.SessionFactoryImpl.(SessionFactoryImpl.java:180)
      [java] at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1213)
      [java] at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuratio
      n.java:631)
      [java] at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configurati
      on.java:760)
      [java] at org.hibernate.ejb.Ejb3Configuration.createFactory(Ejb3Configuration.java:151)
      [java] at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configurati
      on.java:205)
      [java] at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePer
      sistence.java:114)
      [java] at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:37)
      [java] at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:27)
      [java] at com.FirstApp.SSTest.addNS(Unknown Source)
      [java] at com.FirstApp.SSTest.main(Unknown Source)
      [java] Java Result: 1


      Code is some thing like this:
      /**
      * AB generated by hbm2java
      */
      @Entity
      @Table(name="ABs"
      ,schema="Cat"
      , uniqueConstraints = { }
      )

      public class ABs implements java.io.Serializable {
      // Fields
      private NId id;
      private Cdates cdates;
      // Constructors
      /** default constructor */
      public ABs() { }

      /** full constructor */
      public ABs(NId id, Cdates cdates) {
      this.id = id;
      this.cdates = cdates; }
      // Property accessors
      @EmbeddedId
      @AttributeOverrides( {
      @AttributeOverride(name="A",...))
      @AttributeOverride(name="B", ...) ) } )

      public NId getId() { return this.id; }

      public void setId(NId id) { this.id = id; }
      @ManyToOne(cascade={},
      fetch=FetchType.LAZY)
      @JoinColumn(name="A", unique=false, nullable=false, insertable=false, updatable=false)

      ......
      }

      another class
      /**
      * NId generated by hbm2java
      */
      @Embeddable

      public class NId implements java.io.Serializable {
      // Fields
      private String a;
      private String b;
      // Constructors

      /** default constructor */
      public NId() {
      }

      /** full constructor */
      public NId(String a, String b) {
      this.a = a;
      this.b = b;
      }

      // Property accessors
      @Column(name="a", unique=false, nullable=false, insertable=true, updatable=true, length=200)

      public String getA() { return this.a; }

      public void setA(String a) { this.a = a; }
      @Column(name="B", unique=false, nullable=false, insertable=true, updatable=true, length=30)

      public String getB() { return this.b; }

      public void setB(String b) { this.b = b; }

      public boolean equals(Object other){.....}
      public int hashCode() {....)
      }

      and the main class is
      public class SSTest {
      public static void main(String[] arg)
      {
      SSTest sstest = new SSTest();
      sstest.addNS();
      }

      public void addNS()
      {
      EntityManagerFactory emf = Persistence.createEntityManagerFactory("manager1");
      NId item = new NId( "111111", "111111" );

      ABs ns = new ABs();
      ns.setId(item);

      EntityManager em = emf.createEntityManager();
      em.getTransaction().begin();
      em.persist( ns );
      em.getTransaction().commit();
      }// end of method
      }// End of Class