-->
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.  [ 1 post ] 
Author Message
 Post subject: <?xml version="1.0"?> Exception with compos
PostPosted: Fri Feb 23, 2007 1:18 pm 
Newbie

Joined: Fri Feb 16, 2007 1:02 pm
Posts: 2
Hibernate with Spring.
Iam unable to get a load working with a composite key:
Exception in thread "main" org.springframework.orm.hibernate3.HibernateSystemException: Unknown entity: com.fxfn.misp.dto.AttemptTO; nested exception is org.hibernate.MappingException: Unknown entity: com.fxfn.misp.dto.AttemptTO
Caused by: org.hibernate.MappingException: Unknown entity: com.fxfn.misp.dto.AttemptTO .

I think I have the mapping file defined correctly.
Is there a way to enable more logging using hibernate ?

Thanks

Entries in the config file

<bean id="attemptDao" class="com.fxfn.misp.dao.hibernate.HibernateAttemptDao">
<property name="sessionFactory"><ref local="sessionFactory"/></property>
</bean>
=====================================================
Table:

create table fx.attempts (
tracknum number(22) not null,
attempt number(22) not null,
......
primary key (tracknum,attempt)
) ;
====================================================
Mapping File:

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping schema="FX">
<class name="com.fxfn.misp.dto.AttemptsTO" table="attempts" lazy="false">
<composite-id name="attemptPK"
class="org.example.composite.AttemptPK" >
<key-property name="attempt" type="long" column="ATTEMPT"/>
<key-property name="tracknum" type="com.fxfn.misp.domain.Schedule" column="TRACKNUM">
</composite-id>
<property name="attempt_started" column="ATTEMPT_STARTED" type="date"/>
<property name="attempt_completed" column="ATTEMPT_COMPLETED" type="date"/>
<property name="status_def" column="STATUS_DEF" type="string" length="22"/>
<property name="message" column="MESSAGE" type="string" length="2000"/>
</class>
</hibernate-mapping>
======================================================
Classes: Transfer Objects:
//AttemptTo.java
package com.fxfn.misp.dto;

import java.util.Date;

public class AttemptTO {

// Private Fields.
private Date attemptCompleted;
private Date attemptStarted;
private String message;
private long statusDef;
AttemptPK attemptPK;

public AttemptPK getAttemptPK() {
return attemptPK;
}

public void setAttemptPK(AttemptPK attemptPK) {
this.attemptPK = attemptPK;
}

public AttemptTO() {
}

public AttemptTO(AttemptPK attemptPK){
this.attemptPK= attemptPK;
}

/**
* @return the attemptCompleted
*/
public Date getAttemptCompleted() {
return attemptCompleted;
}
/**
* @param attemptCompleted the attemptCompleted to set
*/
public void setAttemptCompleted(Date attemptCompleted) {
this.attemptCompleted = attemptCompleted;
}

/**
* @return the attemptStarted
*/
public Date getAttemptStarted() {
return attemptStarted;
}
/**
* @param attemptStarted the attemptStarted to set
*/
public void setAttemptStarted(Date attemptStarted) {
this.attemptStarted = attemptStarted;
}

/**
* @return the message
*/
public String getMessage() {
return message;
}
/**
* @param message the message to set
*/
public void setMessage(String message) {
this.message = message;
}

/**
* @return the statusDef
*/
public long getStatusDef() {
return statusDef;
}
/**
* @param statusDef the statusDef to set
*/
public void setStatusDef(long statusDef) {
this.statusDef = statusDef;
}

public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("{ ")
.append("attempt=") .append(this.attemptPK.getAttempt()) .append("; ")
.append("attemptCompleted=") .append(attemptCompleted) .append("; ")
.append("attemptStarted=") .append(attemptStarted) .append("; ")
.append("message=") .append(message) .append("; ")
.append("statusDef=") .append(statusDef) .append("; ")
.append("tracknum=") .append(this.attemptPK.getTracknum()).append("; ")
.append(" }");
return sb.toString();
}

}
=====================================================
//AttemptPK.java
package com.fxfn.misp.dto;
import java.io.Serializable;

public class AttemptPK implements Serializable {

private static final long serialVersionUID = 1L;
private long attempt;
private long tracknum;

public long getAttempt() {
return attempt;
}

public void setAttempt(long attempt) {
this.attempt = attempt;
}

public long getTracknum() {
return tracknum;
}

public void setTracknum(long tracknum) {
this.tracknum = tracknum;
}

public boolean equals(Object obj) {
if ( this == obj )
return true;
if ( obj == null )
return false;
if ( !(obj instanceof AttemptPK) )
return false;

final AttemptPK other = (AttemptPK) obj;

if (this.getAttempt() != other.getAttempt())
return false;
if (this.getTracknum() != other.getTracknum())
return false;

return true;
}

public int hashCode() {
int result = 0;
result = result * 29 + (int)tracknum;
result = result * 29 + (int)attempt;
return result;
}
}
=========================================================

package com.fxfn.misp.dao.hibernate;


import org.springframework.dao.DataAccessException;
import org.springframework.dao.EmptyResultDataAccessException;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.fxfn.misp.dto.AttemptTO;
import com.fxfn.misp.dto.AttemptPK;
import com.fxfn.misp.dao.AttemptDao;

public class HibernateAttemptDao extends HibernateDaoSupport
implements AttemptDao {

public HibernateAttemptDao() {
}

public AttemptTO find(long tracknum,long attempt) throws DataAccessException {
AttemptPK attempPK = new AttemptPK();
attempPK.setAttempt(attempt);
attempPK.setTracknum(tracknum);
try {
return (AttemptTO) getHibernateTemplate().load(AttemptTO.class,attempPK);
} catch (EmptyResultDataAccessException e) {
return null;
}
}
}
======================================================
Driver:

package com.fxfn.newgen.test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.fxfn.misp.dao.AttemptDao;
import com.fxfn.misp.dto.AttemptTO;

public class HibernateDbApp {

public static void main(String[] args) {

ApplicationContext ctx = new
ClassPathXmlApplicationContext("hibernateApplicationContext.xml");

//************************************************************************//
//Composite Key
//************************************************************************//

long tracknum = 135650718;
long attempt = 1;

AttemptDao attemptDao = null;
attemptDao = (AttemptDao) ctx.getBean("attemptDao");
AttemptTO attempto = attemptDao.find (tracknum,attempt);

if (attempto == null)
System.out.println("No attempt found for"+
" tracknum=" + tracknum);
else
{
//System.out.println("Schedule: " + sched);
System.out.println("Attempt found:" +
" tracknum=" + attempto.getAttemptPK().getTracknum() +
" prov_id=" + attempto.getAttemptPK().getAttempt());
}
}
}

==============================================
Error:

2007-02-23 11:14:15,633 INFO [org.springframework.core.CollectionFactory] - <JDK 1.4+ collections available>
2007-02-23 11:14:15,634 INFO [org.springframework.core.CollectionFactory] - <Commons Collections 3.x available>
2007-02-23 11:14:15,737 INFO [org.springframework.beans.factory.xml.XmlBeanDefinitionReader] - <Loading XML bean definitions from class path resource [hibernateApplicationContext.xml]>
2007-02-23 11:14:15,997 INFO [org.springframework.context.support.ClassPathXmlApplicationContext] - <Bean factory for application context [org.springframework.context.support.ClassPathXmlApplicationContext;hashCode=11850709]: org.springframework.beans.factory.support.DefaultListableBeanFactory defining beans [propertyConfigurer,dataSource,scheduleDao,attemptDao,sessionFactory,transactionManager]; root of BeanFactory hierarchy>
2007-02-23 11:14:16,005 INFO [org.springframework.context.support.ClassPathXmlApplicationContext] - <6 beans defined in application context [org.springframework.context.support.ClassPathXmlApplicationContext;hashCode=11850709]>
2007-02-23 11:14:16,168 INFO [org.springframework.beans.factory.config.PropertyPlaceholderConfigurer] - <Loading properties file from class path resource [jdbc.properties]>
2007-02-23 11:14:16,178 INFO [org.springframework.context.support.ClassPathXmlApplicationContext] - <Unable to locate MessageSource with name 'messageSource': using default [org.springframework.context.support.DelegatingMessageSource@86c347]>
2007-02-23 11:14:16,181 INFO [org.springframework.context.support.ClassPathXmlApplicationContext] - <Unable to locate ApplicationEventMulticaster with name 'applicationEventMulticaster': using default [org.springframework.context.event.SimpleApplicationEventMulticaster@e5b723]>
2007-02-23 11:14:16,182 INFO [org.springframework.beans.factory.support.DefaultListableBeanFactory] - <Pre-instantiating singletons in factory [org.springframework.beans.factory.support.DefaultListableBeanFactory defining beans [propertyConfigurer,dataSource,scheduleDao,attemptDao,sessionFactory,transactionManager]; root of BeanFactory hierarchy]>
2007-02-23 11:14:16,348 INFO [org.hibernate.cfg.Environment] - <Hibernate 3.2.2>
2007-02-23 11:14:16,353 INFO [org.hibernate.cfg.Environment] - <hibernate.properties not found>
2007-02-23 11:14:16,356 INFO [org.hibernate.cfg.Environment] - <Bytecode provider name : cglib>
2007-02-23 11:14:16,360 INFO [org.hibernate.cfg.Environment] - <using JDK 1.4 java.sql.Timestamp handling>
2007-02-23 11:14:16,752 INFO [org.hibernate.cfg.HbmBinder] - <Mapping class: com.fxfn.misp.dto.SQLReportTO -> SQL_REPORT>
2007-02-23 11:14:16,770 INFO [org.hibernate.cfg.HbmBinder] - <Mapping class: com.fxfn.misp.dto.JobTO -> job>
2007-02-23 11:14:16,773 INFO [org.hibernate.cfg.HbmBinder] - <Mapping class: com.fxfn.misp.dto.ScheduleTO -> schedule>
2007-02-23 11:14:16,777 INFO [org.hibernate.cfg.HbmBinder] - <Mapping class: com.fxfn.misp.dto.JenkinsConfTO -> jenkins_conf>
2007-02-23 11:14:16,778 INFO [org.springframework.orm.hibernate3.LocalSessionFactoryBean] - <Building new Hibernate SessionFactory>
2007-02-23 11:14:16,902 INFO [org.hibernate.connection.ConnectionProviderFactory] - <Initializing connection provider: org.springframework.orm.hibernate3.LocalDataSourceConnectionProvider>
2007-02-23 11:14:18,339 INFO [org.hibernate.cfg.SettingsFactory] - <RDBMS: Oracle, version: Oracle9i Enterprise Edition Release 9.2.0.8.0 - 64bit Production
With the Partitioning and Oracle Data Mining options
JServer Release 9.2.0.8.0 - Production>
2007-02-23 11:14:18,350 INFO [org.hibernate.cfg.SettingsFactory] - <JDBC driver: Oracle JDBC driver, version: 9.2.0.6.0>
2007-02-23 11:14:18,378 INFO [org.hibernate.dialect.Dialect] - <Using dialect: org.hibernate.dialect.OracleDialect>
2007-02-23 11:14:18,386 INFO [org.hibernate.transaction.TransactionFactoryFactory] - <Using default transaction strategy (direct JDBC transactions)>
2007-02-23 11:14:18,388 INFO [org.hibernate.transaction.TransactionManagerLookupFactory] - <No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)>
2007-02-23 11:14:18,389 INFO [org.hibernate.cfg.SettingsFactory] - <Automatic flush during beforeCompletion(): disabled>
2007-02-23 11:14:18,389 INFO [org.hibernate.cfg.SettingsFactory] - <Automatic session close at end of transaction: disabled>
2007-02-23 11:14:18,389 INFO [org.hibernate.cfg.SettingsFactory] - <JDBC batch size: 15>
2007-02-23 11:14:18,389 INFO [org.hibernate.cfg.SettingsFactory] - <JDBC batch updates for versioned data: disabled>
2007-02-23 11:14:18,390 INFO [org.hibernate.cfg.SettingsFactory] - <Scrollable result sets: enabled>
2007-02-23 11:14:18,393 INFO [org.hibernate.cfg.SettingsFactory] - <JDBC3 getGeneratedKeys(): disabled>
2007-02-23 11:14:18,393 INFO [org.hibernate.cfg.SettingsFactory] - <Connection release mode: on_close>
2007-02-23 11:14:18,393 INFO [org.hibernate.cfg.SettingsFactory] - <Default batch fetch size: 1>
2007-02-23 11:14:18,394 INFO [org.hibernate.cfg.SettingsFactory] - <Generate SQL with comments: disabled>
2007-02-23 11:14:18,394 INFO [org.hibernate.cfg.SettingsFactory] - <Order SQL updates by primary key: disabled>
2007-02-23 11:14:18,394 INFO [org.hibernate.cfg.SettingsFactory] - <Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory>
2007-02-23 11:14:18,397 INFO [org.hibernate.hql.ast.ASTQueryTranslatorFactory] - <Using ASTQueryTranslatorFactory>
2007-02-23 11:14:18,397 INFO [org.hibernate.cfg.SettingsFactory] - <Query language substitutions: {}>
2007-02-23 11:14:18,397 INFO [org.hibernate.cfg.SettingsFactory] - <JPA-QL strict compliance: disabled>
2007-02-23 11:14:18,397 INFO [org.hibernate.cfg.SettingsFactory] - <Second-level cache: enabled>
2007-02-23 11:14:18,397 INFO [org.hibernate.cfg.SettingsFactory] - <Query cache: disabled>
2007-02-23 11:14:18,397 INFO [org.hibernate.cfg.SettingsFactory] - <Cache provider: org.hibernate.cache.NoCacheProvider>
2007-02-23 11:14:18,397 INFO [org.hibernate.cfg.SettingsFactory] - <Optimize cache for minimal puts: disabled>
2007-02-23 11:14:18,398 INFO [org.hibernate.cfg.SettingsFactory] - <Structured second-level cache entries: disabled>
2007-02-23 11:14:18,414 INFO [org.hibernate.cfg.SettingsFactory] - <Echoing all SQL to stdout>
2007-02-23 11:14:18,414 INFO [org.hibernate.cfg.SettingsFactory] - <Statistics: disabled>
2007-02-23 11:14:18,415 INFO [org.hibernate.cfg.SettingsFactory] - <Deleted entity synthetic identifier rollback: disabled>
2007-02-23 11:14:18,415 INFO [org.hibernate.cfg.SettingsFactory] - <Default entity-mode: pojo>
2007-02-23 11:14:18,415 INFO [org.hibernate.cfg.SettingsFactory] - <Named query checking : enabled>
2007-02-23 11:14:18,506 INFO [org.hibernate.impl.SessionFactoryImpl] - <building session factory>
2007-02-23 11:14:18,796 INFO [org.hibernate.impl.SessionFactoryObjectFactory] - <Not binding factory to JNDI, no JNDI name configured>
2007-02-23 11:14:18,880 INFO [org.springframework.orm.hibernate3.HibernateTransactionManager] - <Using DataSource [org.apache.commons.dbcp.BasicDataSource@b7ec5d] of Hibernate SessionFactory for HibernateTransactionManager>
Hibernate: select scheduleto0_.tracknum as tracknum2_0_, scheduleto0_.attempt as attempt2_0_, scheduleto0_.batch_max as batch3_2_0_, scheduleto0_.completed_time as completed4_2_0_, scheduleto0_.conf_name as conf5_2_0_, scheduleto0_.destination_id as destinat6_2_0_, scheduleto0_.expedite_time as expedite7_2_0_, scheduleto0_.last_attempt_time as last8_2_0_, scheduleto0_.location_id as location9_2_0_, scheduleto0_.max_attempts as max10_2_0_, scheduleto0_.orig_scheduled_time as orig11_2_0_, scheduleto0_.process_method as process12_2_0_, scheduleto0_.prov_class as prov13_2_0_, scheduleto0_.prov_id as prov14_2_0_, scheduleto0_.retry_param as retry15_2_0_, scheduleto0_.scheduled_time as scheduled16_2_0_, scheduleto0_.status as status2_0_, scheduleto0_.submitted_time as submitted18_2_0_ from fx.schedule scheduleto0_ where scheduleto0_.tracknum=?
Schedule found: tracknum=117647224 prov_id=FX::RealTime::AutoUpdateProcessor
Hibernate: select scheduleto0_.tracknum as tracknum2_0_, scheduleto0_.attempt as attempt2_0_, scheduleto0_.batch_max as batch3_2_0_, scheduleto0_.completed_time as completed4_2_0_, scheduleto0_.conf_name as conf5_2_0_, scheduleto0_.destination_id as destinat6_2_0_, scheduleto0_.expedite_time as expedite7_2_0_, scheduleto0_.last_attempt_time as last8_2_0_, scheduleto0_.location_id as location9_2_0_, scheduleto0_.max_attempts as max10_2_0_, scheduleto0_.orig_scheduled_time as orig11_2_0_, scheduleto0_.process_method as process12_2_0_, scheduleto0_.prov_class as prov13_2_0_, scheduleto0_.prov_id as prov14_2_0_, scheduleto0_.retry_param as retry15_2_0_, scheduleto0_.scheduled_time as scheduled16_2_0_, scheduleto0_.status as status2_0_, scheduleto0_.submitted_time as submitted18_2_0_ from fx.schedule scheduleto0_ where scheduleto0_.tracknum=?
Schedule found: tracknum=117647225 prov_id=MISP::Email
Hibernate: select scheduleto0_.tracknum as tracknum2_0_, scheduleto0_.attempt as attempt2_0_, scheduleto0_.batch_max as batch3_2_0_, scheduleto0_.completed_time as completed4_2_0_, scheduleto0_.conf_name as conf5_2_0_, scheduleto0_.destination_id as destinat6_2_0_, scheduleto0_.expedite_time as expedite7_2_0_, scheduleto0_.last_attempt_time as last8_2_0_, scheduleto0_.location_id as location9_2_0_, scheduleto0_.max_attempts as max10_2_0_, scheduleto0_.orig_scheduled_time as orig11_2_0_, scheduleto0_.process_method as process12_2_0_, scheduleto0_.prov_class as prov13_2_0_, scheduleto0_.prov_id as prov14_2_0_, scheduleto0_.retry_param as retry15_2_0_, scheduleto0_.scheduled_time as scheduled16_2_0_, scheduleto0_.status as status2_0_, scheduleto0_.submitted_time as submitted18_2_0_ from fx.schedule scheduleto0_ where scheduleto0_.tracknum=?
Schedule found: tracknum=117647226 prov_id=FX::RealTime::AutoUpdateProcessor
Hibernate: select scheduleto0_.tracknum as tracknum2_0_, scheduleto0_.attempt as attempt2_0_, scheduleto0_.batch_max as batch3_2_0_, scheduleto0_.completed_time as completed4_2_0_, scheduleto0_.conf_name as conf5_2_0_, scheduleto0_.destination_id as destinat6_2_0_, scheduleto0_.expedite_time as expedite7_2_0_, scheduleto0_.last_attempt_time as last8_2_0_, scheduleto0_.location_id as location9_2_0_, scheduleto0_.max_attempts as max10_2_0_, scheduleto0_.orig_scheduled_time as orig11_2_0_, scheduleto0_.process_method as process12_2_0_, scheduleto0_.prov_class as prov13_2_0_, scheduleto0_.prov_id as prov14_2_0_, scheduleto0_.retry_param as retry15_2_0_, scheduleto0_.scheduled_time as scheduled16_2_0_, scheduleto0_.status as status2_0_, scheduleto0_.submitted_time as submitted18_2_0_ from fx.schedule scheduleto0_ where scheduleto0_.tracknum=?
Schedule found: tracknum=117647227 prov_id=FX::RealTime::AutoUpdateProcessor
Exception in thread "main" org.springframework.orm.hibernate3.HibernateSystemException: Unknown entity: com.fxfn.misp.dto.AttemptTO; nested exception is org.hibernate.MappingException: Unknown entity: com.fxfn.misp.dto.AttemptTO
Caused by: org.hibernate.MappingException: Unknown entity: com.fxfn.misp.dto.AttemptTO
at org.hibernate.impl.SessionFactoryImpl.getEntityPersister(SessionFactoryImpl.java:550)
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 org.springframework.orm.hibernate3.HibernateTemplate$3.doInHibernate(HibernateTemplate.java:503)
at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:367)
at org.springframework.orm.hibernate3.HibernateTemplate.load(HibernateTemplate.java:497)
at org.springframework.orm.hibernate3.HibernateTemplate.load(HibernateTemplate.java:491)
at com.fxfn.misp.dao.hibernate.HibernateAttemptDao.find(HibernateAttemptDao.java:23)
at com.fxfn.newgen.test.HibernateDbApp.main(HibernateDbApp.java:46)


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

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.