-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Annotated classes in seperate Jar file
PostPosted: Tue Feb 20, 2007 10:33 am 
Newbie

Joined: Fri Dec 22, 2006 2:32 pm
Posts: 16
Hello,

I have placed my annotated hibernate classes inside a seperate "commons" jar file. Inside this file I have placed the hibernate.cfg.xml file which looks like this:

Code:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
    <session-factory>
        <property name="hibernate.connection.driver_class">org.gjt.mm.mysql.Driver</property>
        <property name="hibernate.connection.password">xxx</property>
        <property name="hibernate.connection.url">jdbc:mysql:///DevsidenNy</property>
        <property name="hibernate.connection.username">xxx</property>
        <property name="hibernate.current_session_context_class">thread</property>
        <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
        <property name="hibernate.show_sql">true</property>


      <mapping class="info.devsiden.dsj.persistancetier.data.BildeData" />
      <mapping class="info.devsiden.dsj.persistancetier.data.BildeAlbumData" />
      
   </session-factory>
</hibernate-configuration>



Now, when I deploy the application this file is read, which outputs the following:

Code:
14:37:43,671 INFO  [Configuration] configuring from resource: /hibernate.cfg.xml
14:37:43,671 INFO  [Configuration] Configuration resource: /hibernate.cfg.xml
14:37:43,679 INFO  [Configuration] Configured SessionFactory: null
14:37:43,691 INFO  [DriverManagerConnectionProvider] Using Hibernate built-in connection pool (not for production use!)
14:37:43,691 INFO  [DriverManagerConnectionProvider] Hibernate connection pool size: 20
14:37:43,692 INFO  [DriverManagerConnectionProvider] autocommit mode: false
14:37:43,692 INFO  [DriverManagerConnectionProvider] using driver: org.gjt.mm.mysql.Driver at URL: jdbc:mysql:///DevsidenNy
14:37:43,692 INFO  [DriverManagerConnectionProvider] connection properties: {user=xxx, password=xxx}
14:37:43,722 INFO  [SettingsFactory] RDBMS: MySQL, version: 5.0.20-standard
14:37:43,722 INFO  [SettingsFactory] JDBC driver: MySQL-AB JDBC Driver, version: mysql-connector-java-3.1.12 ( $Date: 2005-11-17 15:53:48 +0100 (Thu, 17 Nov 2005) $, $Revision$ )
14:37:43,723 INFO  [Dialect] Using dialect: org.hibernate.dialect.MySQLDialect
14:37:43,723 INFO  [TransactionFactoryFactory] Using default transaction strategy (direct JDBC transactions)
14:37:43,724 INFO  [TransactionManagerLookupFactory] No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
14:37:43,724 INFO  [SettingsFactory] Automatic flush during beforeCompletion(): disabled
14:37:43,724 INFO  [SettingsFactory] Automatic session close at end of transaction: disabled
14:37:43,724 INFO  [SettingsFactory] JDBC batch size: 15
14:37:43,724 INFO  [SettingsFactory] JDBC batch updates for versioned data: disabled
14:37:43,724 INFO  [SettingsFactory] Scrollable result sets: enabled
14:37:43,724 INFO  [SettingsFactory] JDBC3 getGeneratedKeys(): enabled
14:37:43,724 INFO  [SettingsFactory] Connection release mode: auto
14:37:43,724 INFO  [SettingsFactory] Maximum outer join fetch depth: 2
14:37:43,724 INFO  [SettingsFactory] Default batch fetch size: 1
14:37:43,725 INFO  [SettingsFactory] Generate SQL with comments: disabled
14:37:43,725 INFO  [SettingsFactory] Order SQL updates by primary key: disabled
14:37:43,725 INFO  [SettingsFactory] Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
14:37:43,725 INFO  [ASTQueryTranslatorFactory] Using ASTQueryTranslatorFactory
14:37:43,725 INFO  [SettingsFactory] Query language substitutions: {}
14:37:43,726 INFO  [SettingsFactory] JPA-QL strict compliance: disabled
14:37:43,726 INFO  [SettingsFactory] Second-level cache: enabled
14:37:43,726 INFO  [SettingsFactory] Query cache: disabled
14:37:43,726 INFO  [SettingsFactory] Cache provider: org.hibernate.cache.NoCacheProvider
14:37:43,727 INFO  [SettingsFactory] Optimize cache for minimal puts: disabled
14:37:43,727 INFO  [SettingsFactory] Structured second-level cache entries: disabled
14:37:43,727 INFO  [SettingsFactory] Echoing all SQL to stdout
14:37:43,727 INFO  [SettingsFactory] Statistics: disabled
14:37:43,727 INFO  [SettingsFactory] Deleted entity synthetic identifier rollback: disabled
14:37:43,727 INFO  [SettingsFactory] Default entity-mode: pojo
14:37:43,732 INFO  [SessionFactoryImpl] building session factory
14:37:43,733 INFO  [SessionFactoryObjectFactory] Not binding factory to JNDI, no JNDI name configured


Note that there is no reading of these annotated classes (which are correct BTW, with @Entity, and such).

Now, when I try to use any of the annotated classes, I get the following exception:

org.hibernate.MappingException: Unknown entity: info.devsiden.dsj.persistancetier.data.BildeAlbumData
at org.hibernate.impl.SessionFactoryImpl.getEntityPersister(SessionFactoryImpl.java:548)
at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:68)
at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:878)
at org.hibernate.impl.SessionImpl.load(SessionImpl.java:795)
at org.hibernate.impl.SessionImpl.load(SessionImpl.java:788)
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.hibernate.context.ThreadLocalSessionContext$TransactionProtectionWrapper.invoke(ThreadLocalSessionContext.java:301)
at $Proxy73.load(Unknown Source)
at info.devsiden.dsj.persistancetier.dao.data.BildeDao.getBildeAlbum(BildeDao.java:58)
at org.apache.jsp.testHibernate_jsp._jspService(org.apache.jsp.testHibernate_jsp:85)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:39)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:159)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:59)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
at java.lang.Thread.run(Thread.java:613)


Top
 Profile  
 
 Post subject: One of the classes...
PostPosted: Tue Feb 20, 2007 10:44 am 
Newbie

Joined: Fri Dec 22, 2006 2:32 pm
Posts: 16
Here is one of the annotated classes for reference:

package info.devsiden.dsj.persistancetier.data;

Code:
import org.hibernate.annotations.Proxy;

import javax.persistence.*;
import java.util.Date;
import java.util.Set;
import java.util.List;
import java.util.Collection;

/**
* Created by IntelliJ IDEA.
* User: jhb
* Date: Dec 18, 2006
* Time: 7:25:30 PM
* To change this template use File | Settings | File Templates.
*/

@Entity()
@Proxy(lazy=false)
@Table(name="BildeAlbum")
public class BildeAlbumData
{
   private int bildeAlbumID;
   private String bildeAlbumNavn;
   private String bildeAlbumBeskrivelse;
   private Date bildeAlbumOpprettet;
   private Date bildeAlbumSistEndret;
   private boolean bildeAlbumErPrivat;
   private String brukernavn;
   private List<BildeData> bilder;

   @Id
   @GeneratedValue(strategy= GenerationType.AUTO)
   @Column(updatable = false, name="BildeAlbumID", nullable = false)
   public int getBildeAlbumID()
   {
      return bildeAlbumID;
   }

   public void setBildeAlbumID(int bildeAlbumID)
   {
      this.bildeAlbumID = bildeAlbumID;
   }

   @Column(updatable = false, name="BildeAlbumNavn", nullable = false)
   public String getBildeAlbumNavn()
   {
      return bildeAlbumNavn;
   }

   public void setBildeAlbumNavn(String bildeAlbumNavn)
   {
      this.bildeAlbumNavn = bildeAlbumNavn;
   }

   @Column(updatable = false, name="BildeAlbumBeskrivelse", nullable = false)
   public String getBildeAlbumBeskrivelse()
   {
      return bildeAlbumBeskrivelse;
   }

   public void setBildeAlbumBeskrivelse(String bildeAlbumBeskrivelse)
   {
      this.bildeAlbumBeskrivelse = bildeAlbumBeskrivelse;
   }

   @Column(updatable = false, name="BildeAlbumOpprettet", nullable = false)
   public Date getBildeAlbumOpprettet()
   {
      return bildeAlbumOpprettet;
   }

   public void setBildeAlbumOpprettet(Date bildeAlbumOpprettet)
   {
      this.bildeAlbumOpprettet = bildeAlbumOpprettet;
   }

   @Column(updatable = false, name="BildeAlbumSistEndret", nullable = false)
   public Date getBildeAlbumSistEndret()
   {
      return bildeAlbumSistEndret;
   }

   public void setBildeAlbumSistEndret(Date bildeAlbumSistEndret)
   {
      this.bildeAlbumSistEndret = bildeAlbumSistEndret;
   }


   @Column(updatable = false, name="BildeAlbumErPrivat", nullable = false)
   public boolean isBildeAlbumErPrivat()
   {
      return bildeAlbumErPrivat;
   }

   public void setBildeAlbumErPrivat(boolean bildeAlbumErPrivat)
   {
      this.bildeAlbumErPrivat = bildeAlbumErPrivat;
   }

   @Column(updatable = false, name="Brukernavn", nullable = false)
   public String getBrukernavn()
   {
      return brukernavn;
   }

   public void setBrukernavn(String brukernavn)
   {
      this.brukernavn = brukernavn;
   }

   @OneToMany(
         targetEntity=info.devsiden.dsj.persistancetier.data.BildeData.class,
         cascade={CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REFRESH},
         fetch = FetchType.EAGER
   )
   @JoinTable(
      name="BildeAlbumBilde",
      joinColumns = {@JoinColumn(name="BildeAlbumID")},
      inverseJoinColumns = {@JoinColumn(name="BildeID")}
   )
   public Collection<BildeData> getBilder()
   {
      return bilder;
   }

   public void setBilder(List<BildeData> bilder)
   {
      this.bilder = bilder;
   }
}


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.