-->
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: Mapping Exception With a Unidirectional Mapping Reference
PostPosted: Mon Aug 15, 2005 4:53 pm 
Beginner
Beginner

Joined: Mon Aug 15, 2005 4:37 pm
Posts: 27
Location: Washington DC
Hi ,

I have a Java class(A) which is a mapping to a lookup table. Its primary key is referenced as a foreign key in another java class(B) which has a many to one mapping from that other java class(B) to this java class(A).
When i try to create a Criteria based on the first java class(A), with specifying a value for one of the attributes of this class(A), it throws a MappingException specifying that Class(A) as an unknown entity.

[b]Hibernate version:3.0.5

[b]Mapping documents:

Class A Mapping Document
<class
name="ClassA"
table="TableA"
dynamic-update="true"
>
<id
name="modeId"
type="java.math.BigDecimal"
column="MODE_ID"
>
<generator class="assigned" />
</id>


<property
name="rfmode"
type="java.lang.String"
column="RFMODE"
length="100"
/>
</class>

-hibernate-fg.xml
<session-factory >
<!-- local connection properties -->
<property name="hibernate.connection.url">jdbc:oracle:thin:@<username>:1521:<database_name></property>
<property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="hibernate.connection.username">scott</property>
<property name="hibernate.connection.password">scott</property>
<!-- property name="hibernate.connection.pool_size"></property -->

<!-- dialect for Oracle (any version) -->
<property name="dialect">org.hibernate.dialect.OracleDialect</property>

<property name="hibernate.show_sql">false</property>
<!-- <property name="hibernate.transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</property> -->

<property name="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</property>

<mapping resource="a.hbm.xml" />
</session-factory>
</hibernate-configuration>

[b]Code between sessionFactory.openSession() and session.close():[/b]

Example srchExmpl = Example.create(searchObject).excludeNone();
String fullyclassifdclassName = searchObject.getClass().getName();
String reqdclassName = fullyclassifdclassName.substring(fullyclassifdclassName.lastIndexOf(".")+1);
List lstsrchObjects = searchSession.createCriteria(reqdclassName+".class").add(srchExmpl).list();


[b]Full stack trace of any exception that occurs:[/b]

org.hibernate.MappingException: Unknown entity: A.class
at org.hibernate.impl.SessionFactoryImpl.getEntityPersister(SessionFactoryImpl.java:569)
at org.hibernate.impl.SessionImpl.getOuterJoinLoadable(SessionImpl.java:1337)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1303)
at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:300)
at com.dal.common.SearchCommand.execute(SearchCommand.java:56)
at com.dal.test.testclassA.retrieveFreqmode(testclassA.java:36)
at com.dal.test.testclassA.main(testclassA.java:46)

[b]Name and version of the database you are using:[/b]
Oracle 10g

[b]The generated SQL (show_sql=true):[/b]
Not getting to that phase.

[b]Debug level Hibernate log excerpt:[/b]

Hibernate Log Excerpt:
01 [main] INFO connection.DriverManagerConnectionProvider - Using Hibernate built-in connection pool (not for production use!)
701 [main] INFO connection.DriverManagerConnectionProvider - Hibernate connection pool size: 20
701 [main] INFO connection.DriverManagerConnectionProvider - autocommit mode: false
721 [main] INFO connection.DriverManagerConnectionProvider - using driver: oracle.jdbc.driver.OracleDriver at URL: jdbc:oracle:thin:@skanchirajulptp:1521:FAAQA
721 [main] INFO connection.DriverManagerConnectionProvider - connection properties: {user=scott, password=****}
1152 [main] INFO cfg.SettingsFactory - RDBMS: Oracle, version: Oracle Database 10g Enterprise Edition Release 10.1.0.2.0 - Production
With the OLAP and Data Mining options
1152 [main] INFO cfg.SettingsFactory - JDBC driver: Oracle JDBC driver, version: 10.1.0.2.0
1172 [main] INFO dialect.Dialect - Using dialect: org.hibernate.dialect.OracleDialect
1172 [main] INFO transaction.TransactionFactoryFactory - Using default transaction strategy (direct JDBC transactions)
1182 [main] INFO transaction.TransactionManagerLookupFactory - No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
1182 [main] INFO cfg.SettingsFactory - Automatic flush during beforeCompletion(): disabled
1182 [main] INFO cfg.SettingsFactory - Automatic session close at end of transaction: disabled
1182 [main] INFO cfg.SettingsFactory - JDBC batch size: 15
1182 [main] INFO cfg.SettingsFactory - JDBC batch updates for versioned data: disabled
1182 [main] INFO cfg.SettingsFactory - Scrollable result sets: enabled
1182 [main] INFO cfg.SettingsFactory - JDBC3 getGeneratedKeys(): disabled
1182 [main] INFO cfg.SettingsFactory - Connection release mode: null
1182 [main] INFO cfg.SettingsFactory - Default batch fetch size: 1
1182 [main] INFO cfg.SettingsFactory - Generate SQL with comments: disabled
1182 [main] INFO cfg.SettingsFactory - Order SQL updates by primary key: disabled
1182 [main] INFO cfg.SettingsFactory - Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
1182 [main] INFO ast.ASTQueryTranslatorFactory - Using ASTQueryTranslatorFactory
1182 [main] INFO cfg.SettingsFactory - Query language substitutions: {}
1182 [main] INFO cfg.SettingsFactory - Second-level cache: enabled
1182 [main] INFO cfg.SettingsFactory - Query cache: disabled
1182 [main] INFO cfg.SettingsFactory - Cache provider: org.hibernate.cache.EhCacheProvider
1182 [main] INFO cfg.SettingsFactory - Optimize cache for minimal puts: disabled
1182 [main] INFO cfg.SettingsFactory - Structured second-level cache entries: disabled
1232 [main] INFO cfg.SettingsFactory - Statistics: disabled
1232 [main] INFO cfg.SettingsFactory - Deleted entity synthetic identifier rollback: disabled
1232 [main] INFO cfg.SettingsFactory - Default entity-mode: pojo
1352 [main] INFO impl.SessionFactoryImpl - building session factory

Any help would be great.

Thanks,
Surya


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 15, 2005 4:58 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
List lstsrchObjects = searchSession.createCriteria(reqdclassName+".class").add(srchExmpl).list();


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 15, 2005 5:03 pm 
Beginner
Beginner

Joined: Mon Aug 15, 2005 4:37 pm
Posts: 27
Location: Washington DC
Hi gavin,

Are you saying that ".class" is required/not required?
Because what you have specified in this query is exactly same as what i have in my code.
Is there anything else that you are specifying?

gavin wrote:
List lstsrchObjects = searchSession.createCriteria(reqdclassName+".class").add(srchExmpl).list();


Thanks,
Surya


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.