Hello... Hibernate forum!
I've implemented the example in:
http://www.zabada.com/tutorials/hiberna ... xample.php
simplifying it to only one entity: Book. No relations, no foreign keys, no other tables, nothing else.
But, I get:
Quote:
GRAVE: Unknown entity: com.ibm.wpprs.example.Book; nested exception is org.hibernate.MappingException: Unknown entity: com.ibm.wpprs.example.Book
org.springframework.orm.hibernate3.HibernateSystemException: Unknown entity: com.ibm.wpprs.example.Book; nested exception is org.hibernate.MappingException: Unknown entity: com.ibm.wpprs.example.Book
org.hibernate.MappingException: Unknown entity: com.ibm.wpprs.example.Book
at org.hibernate.impl.SessionFactoryImpl.getEntityPersister(SessionFactoryImpl.java:580)
at org.hibernate.impl.SessionImpl.getEntityPersister(SessionImpl.java:1365)
at org.hibernate.engine.ForeignKeys.isTransient(ForeignKeys.java:203)
at org.hibernate.event.def.AbstractSaveEventListener.getEntityState(AbstractSaveEventListener.java:535)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:103)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:93)
at org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:534)
at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:526)
at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:522)
at org.springframework.orm.hibernate3.HibernateTemplate$18.doInHibernate(HibernateTemplate.java:612)
at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:310)
at org.springframework.orm.hibernate3.HibernateTemplate.saveOrUpdate(HibernateTemplate.java:609)
at com.ibm.wpprs.example.BookHibernateDaoImpl.saveBook(BookHibernateDaoImpl.java:13)
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)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:310)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:155)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:122)
at org.springframework.orm.hibernate3.HibernateInterceptor.invoke(HibernateInterceptor.java:161)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:144)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:174)
at $Proxy3.saveBook(Unknown Source)
at com.ibm.wpprs.example.TestMain.main(TestMain.java:23)
Now, I've tried all the traditional:
wrong spelling of the package name. here's my spring configuration xml file:
Quote:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.HSQLDialect</prop>
<prop key="hibernate.connection.driver_class">org.hsqldb.jdbcDriver</prop>
<prop key="hibernate.connection.url">jdbc:hsqldb:mem:z</prop>
<prop key="hibernate.connection.username">sa</prop>
<prop key="hibernate.connection.password"></prop>
<prop key="hibernate.hbm2ddl.auto">create</prop>
<prop key="hibernate.connection.pool_size">1</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.connection.autocommit">true</prop>
</props>
</property>
<property name="annotatedClasses">
<list>
<value>com.ibm.wpprs.example.Book</value>
</list>
</property>
</bean>
<bean id="hibernateInterceptor" class="org.springframework.orm.hibernate3.HibernateInterceptor"
autowire="byName" />
<bean id="service" class="com.ibm.wpprs.example.TestSpring">
<property name="subClass">
<ref bean="subClass" />
</property>
</bean>
<bean id="subClass" class="com.ibm.wpprs.example.TestSubClass">
<property name="name">
<value>Quentin</value>
</property>
</bean>
<bean id="bookDaoTarget" class="com.ibm.wpprs.example.BookHibernateDaoImpl"
autowire="byName" />
<bean id="bookDao" class="org.springframework.aop.framework.ProxyFactoryBean">
<property name="proxyInterfaces">
<value>com.ibm.wpprs.example.BookDao</value>
</property>
<property name="interceptorNames">
<list>
<value>hibernateInterceptor</value>
<value>bookDaoTarget</value>
</list>
</property>
</bean>
</beans>
The class is definitely com.ibm.wpprs.example.Book.
Then, wrong Entity persistence class. In aaaaall my pojos, I have javax.persistence. Here's my class code:
Quote:
package com.ibm.wpprs.example;
import java.io.Serializable;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
@Entity
public class Book implements Serializable{
/**
*
*/
private static final long serialVersionUID = -1L;
@Id
@GeneratedValue (strategy=GenerationType.AUTO)
private long bookId;
public long getBookId() {
return bookId;
}
public void setBookId(long bookId) {
this.bookId = bookId;
}
private String title;
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
}
I was wondering: could it be a problem with the used jars? Ive put all the jars that were inside Hibernate EntityManager 3.4.0 GA, all the "required" from the core one, the spring ones (I've put also the bean example, and it gives me the output "hello Quentin"), the commons collections, pool and dbcp. I've also tried to put a simple data source:
Quote:
<bean id="myDataSource" class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
<property name="driverClassName" value="org.hibernate.dialect.HSQLDialect" />
<property name="url" value="jdbc:hsqldb:mem:z" />
<property name="username" value="sa" />
<property name="password" value="" />
</bean>
And, tried to switch to my local MySQL instance, but I always got to the same exact error.
From the spring forum, all the topics related to that Exception were directing to here.
I was wondering: is there an exact, accurate list of all the jars I have to import, to make basic examples like that one working?
Thank you, I know it's a HUGE amount of stuff! :D