-->
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.  [ 8 posts ] 
Author Message
 Post subject: net.sf.hibernate.MappingException: duplicate import: Product
PostPosted: Thu Dec 04, 2003 2:40 pm 
Newbie

Joined: Thu Dec 04, 2003 2:19 pm
Posts: 6
I am using a config file and no EJB etc
Castor works for me but not Hibernate I'd like to use hibernate cause of the rich feature set.

Exception


et.sf.hibernate.MappingException: Error reading resource: test/mapping.xml
at net.sf.hibernate.cfg.Configuration.addResource(Configuration.java:292)
at net.sf.hibernate.cfg.Configuration.configure(Configuration.java:933)
at net.sf.hibernate.cfg.Configuration.configure(Configuration.java:885)
at net.sf.hibernate.cfg.Configuration.configure(Configuration.java:823)
at test.Test.doCreateOrGetHibernate(Test.java:83)
at test.Test.testhibernateJDO(Test.java:64)
at test.Test.main(Test.java:21)
Caused by: net.sf.hibernate.MappingException: duplicate import: Products
at net.sf.hibernate.cfg.Mappings.addImport(Mappings.java:68)
at net.sf.hibernate.cfg.Binder.bindClass(Binder.java:120)
at net.sf.hibernate.cfg.Binder.bindRootClass(Binder.java:184)
at net.sf.hibernate.cfg.Binder.bindRoot(Binder.java:1146)
at net.sf.hibernate.cfg.Configuration.add(Configuration.java:243)
at net.sf.hibernate.cfg.Configuration.addInputStream(Configuration.java:266)
at net.sf.hibernate.cfg.Configuration.addResource(Configuration.java:289)
... 6 more
New Null Objec



Configuration cf = new Configuration();
cf.configure("/test.cfg.xml");
//never goes past above line

SessionFactory sf = cf.buildSessionFactory();


Configuration file:
<hibernate-configuration>

<session-factory>

<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="show_sql">false</property>
<property name="dialect">net.sf.hibernate.dialect.MySQLDialect</property>

<!-- Mapping files -->
<mapping resource="test/mapping.xml"/>

</session-factory>

</hibernate-configuration>




Mapping FIle:
<?xml version="1.0"?>

<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

<hibernate-mapping>
<class
name="test.Products"
table="NAMES"
dynamic-update="false"
dynamic-insert="false"
>

<id
name="symbol"
column="NAME"
type="String"
length=""
unsaved-value="null"
>
<generator class="">
</generator>
</id>

<property
name="exchange"
type="String"
update="true"
insert="true"
column="EXCHANGE"
not-null="false"
unique="false"
/>

<property
name="blade"
type="String"
update="true"
insert="true"
column="BLADE"
not-null="false"
unique="false"
/>

<property
name="bin"
type="int"
update="true"
insert="true"
column="BIN"
not-null="false"
unique="false"
/>

<property
name="interface"
type="String"
update="true"
insert="true"
column="INTERFACE"
not-null="false"
unique="false"
/>

<property
name="region"
type="String"
update="true"
insert="true"
column="REGION"
not-null="false"
unique="false"
/>

<property
name="binmachine"
type="String"
update="true"
insert="true"
column="BINMACHINE"
not-null="false"
unique="false"
/>


</class>

</hibernate-mapping>


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 04, 2003 3:00 pm 
Newbie

Joined: Sat Aug 30, 2003 12:37 pm
Posts: 16
You are probably importing the Product class/mapping twice.


Top
 Profile  
 
 Post subject: net.sf.hibernate.MappingException: duplicate import: Product
PostPosted: Thu Dec 04, 2003 3:12 pm 
Newbie

Joined: Thu Dec 04, 2003 2:19 pm
Posts: 6
I'm definitely not importing the class twice
I've seen similar posts for the problem but no solution


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 04, 2003 4:37 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
Can you make a main method and a corresponding hbm.xml and config.xml file and reproduce it ? If yes - then show us that and i'll look at it agin.

I used your posting mapping and could not reproduce it!?

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject: Solved ; t.sf.hibernate.MappingException: duplicate import:
PostPosted: Thu Dec 04, 2003 4:46 pm 
Newbie

Joined: Thu Dec 04, 2003 2:19 pm
Posts: 6
Found the issue

I had errors in my mapping file.
String instead f string
generator class was blank

The exception being thrown was the MappedException: duplicate record

The only way I found out was by debuggin right into the hibernate src.
BindColumns or somemethod like that was throwing exceptions


Thx for the feedback anyways




[b]Thing to remember is that[/b]
[i]If there are errors in the mapping file
net.sf.hibernate.MappingException: duplicate import: Product
exception is being thrown[/i]


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 04, 2003 4:55 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
hmm...strange...

That sounds like a "not-so-user-friendly error message"....

I must have been running the wrong mapping when testing coz' i did not get that error.....but I'll encourage you to post a hbm.xml that throws this bad error and then add it to the JIRA

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 04, 2003 5:15 pm 
Newbie

Joined: Thu Dec 04, 2003 2:19 pm
Posts: 6
I've already posted the contents of the configuration file
and the mapping file in my first post.

if u look at the mapping file you'll see the errors in it

type= "String" instead of type="String"

and a empty generator class in the id node

<generator class>
</generator class>

I'm tried this on the release and beta 6 codebases and got the same effect.

I'll add to JIRA I'm new to this so will figure out how.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 04, 2003 5:44 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
ad wrote:
I've already posted the contents of the configuration file
and the mapping file in my first post.


yes - but it's just much easier for us if you attach them as files to a JIRA ;)

Quote:
I'll add to JIRA I'm new to this so will figure out how.


Don't worry it's easy ;)

_________________
Max
Don't forget to rate


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