-->
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: Erreur Parsing xml mapping file
PostPosted: Tue Sep 07, 2004 5:11 am 
Newbie

Joined: Tue Sep 07, 2004 4:39 am
Posts: 4
Hibernate version:
Quote:
2.1.6


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

<hibernate-mapping>
<class name="com.moi.data.ProductVO" table="products">

<id name="id" column="id" type="long">
<generator class="increment"/>
</id>
<property name="name" column="name" type="string"/>
<property name="description" column="description" type="string"/>

<set name="PHasC" role="products_has_components" table="products_has_components">
<key>
<column name="id" not-null="true"/>
</key>
<many-to-many class="com.moi.data.ComponentVO">
<column name="components_id" not-null="true" />
</many-to-many>
</set>

</class>
</hibernate-mapping>

Code between sessionFactory.openSession() and session.close():
Quote:
public Collection getByName(String productName){
Collection products = new ArrayList();
try{
Session session=createSession(ProductVO.class);
//Query q =session.find("SELECT FROM ");
Query q=session.createQuery("from User user WHERE user.id= :name");
q.setString( "name", productName );
products=q.list();
//users=session.find("from Users in class User WHERE User.id="+productName);
}

Full stack trace of any exception that occurs:
Quote:
15:20:27,983 INFO Environment:469 - Hibernate 2.1.6
15:20:28,025 INFO Environment:503 - loaded properties from resource hibernate.properties: {hibernate.connection.driver_class=org.gjt.mm.mysql.Driver, hibernate.cglib.use_reflection_optimizer=true, hibernate.cache.provider_class=net.sf.hibernate.cache.EhCacheProvider, hibernate.cache.use_query_cache=true, hibernate.max_fetch_depth=1, hibernate.dialect=net.sf.hibernate.dialect.MySQLDialect, hibernate.jdbc.use_streams_for_binary=true, hibernate.jdbc.batch_size=0, hibernate.query.substitutions=true 1, false 0, yes 'Y', no 'N', hibernate.proxool.pool_alias=pool1, hibernate.connection.username=bugs, hibernate.cache.region_prefix=hibernate.test, hibernate.connection.url=jdbc:mysql://localhost/bugs2, hibernate.show_sql=true, hibernate.connection.password=bugs, hibernate.jdbc.batch_versioned_data=true, hibernate.connection.pool_size=1}
15:20:28,036 INFO Environment:528 - using java.io streams to persist binary types
15:20:28,038 INFO Environment:529 - using CGLIB reflection optimizer
15:20:28,081 INFO Configuration:350 - Mapping resource: com/moi/data/ProductVO.hbm.xml
15:20:30,415 ERROR XMLHelper:48 - Error parsing XML: XML InputStream(15) Attribute "name" must be declared for element type "set".

Name and version of the database you are using:
Quote:
mysql 3.23

Debug level Hibernate log excerpt:
Quote:


I don't understand why it asks me to declare attribute name for element type set, cause i did it, is someone see a syntax error? I'm quite noob so it can be a really stupid thing.
Thinks for your help.[/quote]


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 07, 2004 5:43 am 
Newbie

Joined: Thu Jun 24, 2004 2:19 am
Posts: 10
the role atttribute is from hibernate 1.x, i think.
check out the DTD for version 2:

and the [url=http://www.hibernate.org/hib_docs/reference/en/html/collections.html#collections-mappinghttp://www.hibernate.org/hib_docs/reference/en/html/collections.html#collections-mapping]hibernate documentation[/url] on how to map collections:

http://www.hibernate.org/hib_docs/refer ... ns-mapping


pascal


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 07, 2004 10:28 am 
Newbie

Joined: Tue Sep 07, 2004 4:39 am
Posts: 4
First i didn't give it the role attribute but hibernate asked for it. So i gave it cause i'm a good boy.
Thinks for your answer.


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.