Joined: Sun Jan 22, 2006 3:27 pm Posts: 11
|
Hibernate version:3.1
Name and version of the database you are using: hdsql
Hi
I know that this exception looks innocuos and a beginner's error but I cannot for the life of me get past it.
I have got Hibernate to work perfectly with externally mapped properties in an xml file per Java class but I keep getting the above error when trying to use Annotations in the Java file. I have re-read the Annotations guide and cannot find any additional task that needs to be completed.
I attach the hibernate.cfg.xml file, the offending java class declaration and the exception log:
######hibernate.cfg.xml file
<?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.cfg.xml file -->
<hibernate-configuration>
<session-factory>
<!-- Hibernate Annotation class mapping -->
<mapping package="peacBudget"/>
<mapping class="peacBudget.Password"/>
<mapping class="peacBudget.TestPassword"/>
<mapping class="peacBudget.User"/>
<mapping class="peacBudget.Customer"/>
<mapping class="peacBudget.AccessManager"/>
<mapping class="peacBudget.AccessLog"/>
<mapping class="peacBudget.BudgetVersion"/>
<mapping class="peacBudget.CompanyDetails"/>
<mapping class="peacBudget.SalariedStaffMemberController"/>
<mapping class="peacBudget.SalariedStaffMember"/>
<mapping class="peacBudget.Rent"/>
<mapping class="peacBudget.Overheads"/>
<mapping class="peacBudget.IncomeStatement"/>
<mapping class="peacBudget.Electricity"/>
<mapping class="peacBudget.CostCenters"/>
<mapping class="peacBudget.BudgetInputController"/>
<!-- <mapping class="peacBudget."/>
<mapping class="peacBudget."/>
<mapping class="peacBudget."/>
-->
<!-- Database connection settings -->
<property name="connection.driver_class">org.hsqldb.jdbcDriver</property>
<property name="connection.url">jdbc:hsqldb:hsql://localhost</property>
<property name="connection.username">sa</property>
<property name="connection.password"></property>
<!-- JDBC connection pool (use the built-in) -->
<property name="connection.pool_size">1</property>
<!-- SQL dialect -->
<property name="dialect">org.hibernate.dialect.HSQLDialect</property>
<!-- Enable Hibernate's automatic session context management -->
<property name="current_session_context_class">thread</property>
<!-- Disable the second-level cache -->
<property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>
<!-- Echo all executed SQL to stdout -->
<property name="show_sql">true</property>
<!-- Drop and re-create the database schema on startup -->
<!-- <property name="hbm2ddl.auto">create</property>
-->
<!-- <property name="hbm2ddl.auto">create</property>
-->
<mapping resource="UserAndAccessPackage.hbm.xml"/>
<!-- <mapping resource=".hbm.xml"/>
-->
<!--
TO GET HSQL SERVER RUNNING
java -classpath lib/hsqldb.jar org.hsqldb.Server
TO RUN ANT
ant run -Daction=store
-->
</session-factory>
</hibernate-configuration>
########PASSWORD JAVA CLASS DECLARATION & ANNOTATIONS:
package peacBudget;
/** @author Fernando de Nobrega 22 January 2006
*/
//hibernate
import java.io.Serializable;
import org.hibernate.*;
import org.hibernate.cfg.*;
import org.hibernate.hql.*;
import javax.persistence.*;
import java.util.*;
import java.util.Date;
import java.io.*;
/**
*
*/
@Embeddable(access = AccessType.FIELD)
public class Password {
///////////////////////////////////////
// attributes
//hibernate optimistic locking
@Version
@Column(name="OPTLOCK")
private Integer version;
@Id(generate=GeneratorType.AUTO)
private Long id;
private String userName;
private Date datePasswordSet;
@Column(unique = true)
private String userEncryptedPassword;
/*Can be the following options:
* - "More than three incorrect"
+"\npassword attempts"
* - "Your password as time lapsed."
*
*/
private String reasonIfPasswordBlocked;
private String managerEncryptedPassword;
private String managerNameForPasswordOveride;
private String employee_OR_customer;
private Vector oldEncryptedPasswordsVector;
private int numberTimesPasswordFailed;
private Date datePasswordExpires;
@Transient
private GregorianCalendar gregorianDatePasswordExpires;
@Transient
private GregorianCalendar gregorianDatePasswordSet;
@Transient
private String blankEncrypted = new Encryptor().encrypt("BLANK");
@Transient
private String blockedEncrypted = new Encryptor().encrypt("BLOCKED");
@Transient
private String usedEncrypted = new Encryptor().encrypt("USED");
@Transient
private String manusedEncrypted = new Encryptor().encrypt("MANUSED");
...... METHODS
###################### EXCEPTION WHEN ABOVE IS RUN
org.hibernate.MappingException: Unknown entity: peacBudget.Password
at org.hibernate.impl.SessionFactoryImpl.getEntityPersister(SessionFactoryImpl.java:512)
at org.hibernate.impl.SessionImpl.getEntityPersister(SessionImpl.java:1272)
at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:89)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:186)
at org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:33)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:175)
at org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:27)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
at org.hibernate.impl.SessionImpl.fireSave(SessionImpl.java:544)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:533)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:529)
at peacBudget.Password.savePasswordObject(Unknown Source)
at peacBudget.TestPassword.main(Unknown Source)
I hope that someone out there can point out where i have gone wrong
Cheers
Fernando
|
|