-->
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.  [ 3 posts ] 
Author Message
 Post subject: No persistent class found
PostPosted: Wed Feb 22, 2006 3:49 am 
Beginner
Beginner

Joined: Wed Aug 04, 2004 4:33 am
Posts: 45
Location: Switzerland
I'm doing a simple test with hibernate 3 and annotations. Here is the code and configuration I have. I get no exception, but a log entry saying that no persistent class has been found.
Any idea? Thanks in advance!

Hibernate version:
Hibernate 3.1.1
Annotations 3.1 beta 8

Mapping documents:
@Entity
@Table(name="table1")
public class PersistentTable1 {

private int id;
private String text;
private Set table2s;

public PersistentTable1() {
}

@Id
public int getId() {
return id;
}

public void setId(int id) {
this.id = id;
}

public String getText() {
return text;
}

public void setText(String text) {
this.text = text;
}

@OneToMany
@JoinColumn(name="table1_id")
public Set getTable2s() {
return table2s;
}

public void setTable2s(Set table2s) {
this.table2s = table2s;
}
}


@Entity
@Table(name="table2")
public class PersistentTable2 {
private int id;
private String description;
private PersistentTable1 table1;

public PersistentTable2() {
}

@Id
public int getId() {
return id;
}

public void setId(int id) {
this.id = id;
}

public String getDescription() {
return description;
}

public void setDescription(String description) {
this.description = description;
}

@ManyToOne(cascade= {CascadeType.ALL} )
@org.hibernate.annotations.Cascade (value=org.hibernate.annotations. CascadeType.DELETE_ORPHAN)
@JoinColumn(name="table1_id")
public PersistentTable1 getTable1() {
return table1;
}

public void setTable1(PersistentTable1 table1) {
this.table1 = table1;
}

/**
* @see java.lang.Object#equals(Object)
*/
public boolean equals(Object object) {
if (!(object instanceof PersistentTable2)) {
return false;
}
PersistentTable2 rhs = (PersistentTable2) object;
return new EqualsBuilder().appendSuper(super.equals(object)).append(this.table1, rhs.table1)
.append(this.description, rhs.description).append(this.id, rhs.id).isEquals();
}

/**
* @see java.lang.Object#hashCode()
*/
public int hashCode() {
return new HashCodeBuilder(-20366931, -259946085).appendSuper(super.hashCode()).append(
this.table1).append(this.description).append(this.id).toHashCode();
}
}

Code between sessionFactory.openSession() and session.close():
public class Main {
public static void main(String[] args) {
Session session = HibernateUtil.getSession();
Query query = session.createQuery("from mapped.PersistentTable1");
List<PersistentTable1> table1s = (List<PersistentTable1>)query.list();
}
}

public class HibernateUtil {
private static final SessionFactory sessionFactory;
static {
try {
sessionFactory = new AnnotationConfiguration().configure().buildSessionFactory();
}
catch (Throwable t) {
throw new ExceptionInInitializerError(t);
}
}
public static Session getSession() throws HibernateException {
return sessionFactory.openSession();
}
}
Full stack trace of any exception that occurs:
15:39:54,256 INFO Environment:479 - Hibernate 3.1.1
15:39:54,272 INFO Environment:494 - loaded properties from resource hibernate.properties: {hibernate.connection.username=nh_user, hibernate.connection.password=****, hibernate.cache.provider_class=org.hibernate.cache.NoCacheProvider, hibernate.cglib.use_reflection_optimizer=true, hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect, hibernate.connection.url=jdbc:postgresql://localhost/horizon, hibernate.connection.driver_class=org.postgresql.Driver}
15:39:54,272 INFO Environment:525 - using CGLIB reflection optimizer
15:39:54,272 INFO Environment:555 - using JDK 1.4 java.sql.Timestamp handling
15:39:54,350 INFO Configuration:1296 - configuring from resource: /hibernate.cfg.xml
15:39:54,350 INFO Configuration:1273 - Configuration resource: /hibernate.cfg.xml
15:39:54,506 INFO Configuration:1407 - Configured SessionFactory: null
15:39:54,553 INFO DriverManagerConnectionProvider:41 - Using Hibernate built-in connection pool (not for production use!)
15:39:54,553 INFO DriverManagerConnectionProvider:42 - Hibernate connection pool size: 20
15:39:54,569 INFO DriverManagerConnectionProvider:45 - autocommit mode: false
15:39:54,569 INFO DriverManagerConnectionProvider:80 - using driver: org.postgresql.Driver at URL: jdbc:postgresql://localhost/horizon
15:39:54,569 INFO DriverManagerConnectionProvider:86 - connection properties: {user=nh_user, password=****}
15:39:54,678 INFO SettingsFactory:77 - RDBMS: PostgreSQL, version: 8.1.1
15:39:54,678 INFO SettingsFactory:78 - JDBC driver: PostgreSQL Native Driver, version: PostgreSQL 8.0 JDBC3g with SSL (build 311)
15:39:54,710 INFO Dialect:103 - Using dialect: org.hibernate.dialect.PostgreSQLDialect
15:39:54,756 INFO TransactionFactoryFactory:31 - Using default transaction strategy (direct JDBC transactions)
15:39:54,756 INFO TransactionManagerLookupFactory:33 - No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
15:39:54,756 INFO SettingsFactory:125 - Automatic flush during beforeCompletion(): disabled
15:39:54,756 INFO SettingsFactory:129 - Automatic session close at end of transaction: disabled
15:39:54,756 INFO SettingsFactory:136 - JDBC batch size: 15
15:39:54,756 INFO SettingsFactory:139 - JDBC batch updates for versioned data: disabled
15:39:54,756 INFO SettingsFactory:144 - Scrollable result sets: enabled
15:39:54,756 INFO SettingsFactory:152 - JDBC3 getGeneratedKeys(): disabled
15:39:54,756 INFO SettingsFactory:160 - Connection release mode: auto
15:39:54,756 INFO SettingsFactory:187 - Default batch fetch size: 1
15:39:54,756 INFO SettingsFactory:191 - Generate SQL with comments: disabled
15:39:54,756 INFO SettingsFactory:195 - Order SQL updates by primary key: disabled
15:39:54,756 INFO SettingsFactory:338 - Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
15:39:54,756 INFO ASTQueryTranslatorFactory:21 - Using ASTQueryTranslatorFactory
15:39:54,756 INFO SettingsFactory:203 - Query language substitutions: {}
15:39:54,756 INFO SettingsFactory:209 - Second-level cache: enabled
15:39:54,756 INFO SettingsFactory:213 - Query cache: disabled
15:39:54,756 INFO SettingsFactory:325 - Cache provider: org.hibernate.cache.NoCacheProvider
15:39:54,772 INFO SettingsFactory:228 - Optimize cache for minimal puts: disabled
15:39:54,772 INFO SettingsFactory:237 - Structured second-level cache entries: disabled
15:39:54,772 INFO SettingsFactory:264 - Statistics: disabled
15:39:54,772 INFO SettingsFactory:268 - Deleted entity synthetic identifier rollback: disabled
15:39:54,772 INFO SettingsFactory:283 - Default entity-mode: pojo
15:39:54,819 INFO SessionFactoryImpl:153 - building session factory
15:39:54,819 INFO SessionFactoryObjectFactory:82 - Not binding factory to JNDI, no JNDI name configured
15:39:54,881 WARN QuerySplitter:116 - no persistent classes found for query class: from mapped.PersistentTable1
15:39:54,897 DEBUG JDBCContext:215 - after autocommit
15:39:54,897 DEBUG ConnectionManager:305 - aggressively releasing JDBC connection

Name and version of the database you are using:
Postgres 8

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:

Configuration:
<?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="connection.driver_class">org.postgresql.Driver</property>
<property name="connection.url">jdbc:postgresql://localhost/horizon</property>
<property name="connection.username">nh_user</property>
<property name="connection.password">nh_user</property>
<property name="dialect ">org.hibernate.dialect.PostgreSQLDialect</property>
<property name="show_sql">true</property>
<property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>

<mapping class="mapped.PersistentTable1" />
<mapping class="mapped.PersistentTable2" />
</session-factory>
</hibernate-configuration>


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 22, 2006 4:12 am 
Pro
Pro

Joined: Mon Jan 24, 2005 5:39 am
Posts: 216
Location: Germany
This usually means that your class PersistentTable1 is not mapped.
You should check package and class names,
classpath etc.

_________________
dont forget to rate !


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 22, 2006 4:20 am 
Beginner
Beginner

Joined: Wed Aug 04, 2004 4:33 am
Posts: 45
Location: Switzerland
I really can't find a problem. Hibernate finds the class specified in the hibernate.cfg.xml file. Because if I change it eighter in the configuration or the query then an exception is thrown.

However if it is correct I'm not getting an exception, but just this warning in the log and the select statement doesn't return anything. But there is data in the database.

I'm also sure, that the connection to the database is done, because if I change the configurationthere, an exception is thrown too.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.