aspose file tools*
The moose likes Object Relational Mapping and the fly likes Could not determine type for: java.util.Set, at table Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Could not determine type for: java.util.Set, at table" Watch "Could not determine type for: java.util.Set, at table" New topic
Author

Could not determine type for: java.util.Set, at table

kiran kumar reddy
Ranch Hand

Joined: Jun 28, 2012
Posts: 94

i am trying a simple application to know how collections are persisted in the database using hibernate. i am using eclipse, hibernate 3.3. as far as my knowledge goes i did it correct. but console error says that i am wrong.console error goes as follows,

21:33:51,354 INFO Version:15 - Hibernate Annotations 3.4.0.GA
21:33:51,363 INFO Environment:560 - Hibernate 3.3.2.GA
21:33:51,364 INFO Environment:593 - hibernate.properties not found
21:33:51,366 INFO Environment:771 - Bytecode provider name : javassist
21:33:51,369 INFO Environment:652 - using JDK 1.4 java.sql.Timestamp handling
21:33:51,416 INFO Version:14 - Hibernate Commons Annotations 3.1.0.GA
21:33:51,417 INFO Configuration:1474 - configuring from resource: /hibernate.cfg.xml
21:33:51,418 INFO Configuration:1451 - Configuration resource: /hibernate.cfg.xml
21:33:51,475 INFO Configuration:1589 - Configured SessionFactory: null
21:33:51,477 INFO HibernateSearchEventListenerRegister:53 - Unable to find org.hibernate.search.event.FullTextIndexEventListener on the classpath. Hibernate Search is not enabled.
21:33:51,510 INFO AnnotationBinder:419 - Binding entity from annotated class: com.hibernate.CollectionDemo.UserDetail
21:33:51,533 INFO EntityBinder:422 - Bind entity com.hibernate.CollectionDemo.UserDetail on table USER_DETAIL_COLLECTIONS
21:33:51,562 INFO AnnotationConfiguration:369 - Hibernate Validator not found: ignoring
Exception in thread "main" org.hibernate.MappingException: Could not determine type for: java.util.Set, at table: USER_DETAIL_COLLECTIONS, for columns: [org.hibernate.mapping.Column(listOfAddress)]
at org.hibernate.mapping.SimpleValue.getType(SimpleValue.java:292)
at org.hibernate.mapping.SimpleValue.isValid(SimpleValue.java:276)
at org.hibernate.mapping.Property.isValid(Property.java:207)
at org.hibernate.mapping.PersistentClass.validate(PersistentClass.java:458)
at org.hibernate.mapping.RootClass.validate(RootClass.java:215)
at org.hibernate.cfg.Configuration.validate(Configuration.java:1149)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1334)
at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:867)
at com.hibernate.CollectionDemo.TestUserDetail.main(TestUserDetail.java:15)


and my model class goes here



here contains the address class which will be embedded in the userdetail class,



here goes my config 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-configuration>

<session-factory>

<!-- Database connection settings -->
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="connection.url">jdbc:mysql://localhost:3306/testDb</property>
<property name="connection.username">root</property>
<property name="connection.password"></property>
<!-- <property name="hibernate.default_schema">TESTSCHEMA</property> -->

<!-- JDBC connection pool (use the built-in) -->
<property name="connection.pool_size">2</property>

<!-- SQL dialect -->
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>

<!-- Enable Hibernate's current session context -->
<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>

<!-- name of the annotated entity class -->
<mapping class="com.hibernate.CollectionDemo.UserDetail"/>

<!--<mapping resource="org/hibernate/tutorial/domain/Event.hbm.xml"/>
<mapping resource="org/hibernate/tutorial/domain/Person.hbm.xml"/>

-->
</session-factory>

</hibernate-configuration>
K. Tsang
Bartender

Joined: Sep 13, 2007
Posts: 2601
    
    9

How are you mapping your Address class to DB table?


K. Tsang JavaRanch SCJP5 SCJD/OCM-JD OCPJP7 OCPWCD5 OCPBCD5
kiran kumar reddy
Ranch Hand

Joined: Jun 28, 2012
Posts: 94

K. Tsang wrote:How are you mapping your Address class to DB table?

Address class is embeddable it means it is embedded in other class ie. userdetail class. you want me to annotate 'entity' for address class also? if yes, i tried it but got same result.
K. Tsang
Bartender

Joined: Sep 13, 2007
Posts: 2601
    
    9

No I meant the <hibernate-mapping> stuff defining DB columns to POJO attributes

I suggest you glance through the Hibernate reference:
Hibernate collection mapping
kiran kumar reddy
Ranch Hand

Joined: Jun 28, 2012
Posts: 94

K. Tsang wrote:No I meant the <hibernate-mapping> stuff defining DB columns to POJO attributes

you mean creating xml file other than hibernate.cfg.xml. here in this application it won't be needed because we are using annotations here. it will be done automatically by hibernate. class name will be converted in to table name and the member variables names will be coonverted in to column names. and this is a video tutorial found in the internet. i did what exactly he did in that tutorial. and he has entire collection of hibernate tutorials and i have been following it from the first video tutorial. now i got stuck in this topic.
K. Tsang
Bartender

Joined: Sep 13, 2007
Posts: 2601
    
    9

If you are using annotations all the way, I suggest you adding @Column(name="blabla") to each of those attributes in the Address class.
kiran kumar reddy
Ranch Hand

Joined: Jun 28, 2012
Posts: 94

K. Tsang wrote:If you are using annotations all the way, I suggest you adding @Column(name="blabla") to each of those attributes in the Address class.

my problem is solved by updating my hibernate version, my version doesn't support element collection annotation.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Could not determine type for: java.util.Set, at table