-->
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: help!!!!!!!!!!!!!!!!!!!!
PostPosted: Sun Jan 18, 2004 4:40 pm 
Newbie

Joined: Sun Jan 18, 2004 4:17 pm
Posts: 3
i encountered an strange problem , i have degubed many times but i cannot deal with it.

why it always says duplicate import: CosmeticBrand
(a class to be pesisted!) when i use the hibernat.cfg.xml and Configuration().configure() to initialze
but when i tried to use Configuration.add(CosmeticBrand.class).add(Product).add(ProductProfile) to initialize instead , no exception was thrown and it could aslo export correct schema!

hibernate.cfg.xml
<hibernate-configuration>
<session-factory>
<mapping resource="com/sirius/webapps/shoppingmall/products/entity/brand/CosmeticBrand.hbm.xml"/>
<mapping resource="com/sirius/webapps/shoppingmall/products/entity/product/CosmeticProduct.hbm.xml"/>
<mapping resource="com/sirius/webapps/shoppingmall/products/ProductProfile.hbm.xml"/>
</session-factory>
</hibernate-configuration>

CosmeticProduct.hbm.xml
here is some xmls
<?xml version="1.0"?>

<hibernate-mapping>
<class
name="com.sirius.webapps.shoppingmall.products.CosmeticProduct"
table="Cosmetic_Products"
dynamic-update="false"
>
<id
name="productID"
column="productID"
type="string"
unsaved-value="any"
>
<generator class="assigned"/>
</id>

<property
name="productName"
type="string"
update="true"
insert="true"
column="Productname"
/>
<one-to-one
name="productProfile"
class="com.sirius.webapps.shoppingmall.products.ProductProfile"
cascade="none"
outer-join="auto"
constrained="false"
/>

<many-to-one name="brand"
class="com.sirius.webapps.shoppingmall.products.CosmeticBrand"
cascade="none"
outer-join="auto"
update="true"
insert="true"
column="brand_id"
/>
</class>
</hibernate-mapping>

CosmeticBrand.hbm.xml<?xml version="1.0"?>

<hibernate-mapping>
<class
name="com.sirius.webapps.shoppingmall.products.CosmeticBrand"
table="Cosmetic_Brand"
dynamic-update="false">

<id
name="brandID"
column="brandID"
type="string"
unsaved-value="any"
>
<generator class="assigned"/>
</id>
<property
name="brandName"
type="string"
update="true"
insert="true"
column="brand_name"


<set name="products"
table="Cosmetic_Products"
lazy="false"
cascade="all"
sort="unsorted"
>
<key column="brand_id"/>
<one-to-many
class="com.sirius.webapps.shoppingmall.products.CosmeticProduct"/>
</set>




</class>
</hibernate-mapping>

ProductProfile.hbm.xml
<?xml version="1.0"?>

<hibernate-mapping>
<class
name="com.sirius.webapps.shoppingmall.products.ProductProfile"
table="Products_Profile"
dynamic-update="false">

<id
name="id"
column="ID"
type="string"
unsaved-value="any"
>
<generator class="assigned"/>
</id>
<property
name="quantity"
type="integer"
update="true"
insert="true"
column="Quantity"
/>

</class>
</hibernate-mapping>

CosmeticProduct and CosmeticBrand has a many to one relationship
and an one to one between CosmeticProduct and ProductProfile

when i eliminated
<set name="products"
table="Cosmetic_Products"
lazy="false"
cascade="all"
sort="unsorted"
>
<key column="brand_id"/>
<one-to-many
class="com.sirius.webapps.shoppingmall.products.CosmeticProduct"/>
</set>


in CosmeticBrand.hbm.xml, no exception was found but an incorrect shema was created. i donnot what on earth was wrong ! plz help me
THX!!!!!
log4j:WARN No appenders could be found for logger (net.sf.hibernate.cfg.Environment).
log4j:WARN Please initialize the log4j system properly.
net.sf.hibernate.MappingException: Error reading resource: com/sirius/webapps/shoppingmall/products/entity/brand/CosmeticBrand.hbm.xml
at net.sf.hibernate.cfg.Configuration.addResource(Configuration.java:307)
at net.sf.hibernate.cfg.Configuration.doConfigure(Configuration.java:957)
at net.sf.hibernate.cfg.Configuration.doConfigure(Configuration.java:909)
at net.sf.hibernate.cfg.Configuration.configure(Configuration.java:845)
at net.sf.hibernate.cfg.Configuration.configure(Configuration.java:831)
at test.GenerateSchema.main(GenerateSchema.java:23)
Caused by: net.sf.hibernate.MappingException: duplicate import: CosmeticBrand
at net.sf.hibernate.cfg.Mappings.addImport(Mappings.java:82)
at net.sf.hibernate.cfg.Binder.bindClass(Binder.java:126)
at net.sf.hibernate.cfg.Binder.bindRootClass(Binder.java:217)
at net.sf.hibernate.cfg.Binder.bindRoot(Binder.java:1204)
at net.sf.hibernate.cfg.Configuration.add(Configuration.java:247)
at net.sf.hibernate.cfg.Configuration.addInputStream(Configuration.java:281)
at net.sf.hibernate.cfg.Configuration.addResource(Configuration.java:304)
... 5 more


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jan 18, 2004 6:31 pm 
Proxool Developer
Proxool Developer

Joined: Tue Aug 26, 2003 10:42 am
Posts: 373
Location: Belgium
Start by configuring Log4J properly and you will many more messages before your stacktrace.... Sure they will help you to understand what's going on.

Moreover, your log prints:
Code:
net.sf.hibernate.MappingException: Error reading resource: com/sirius/webapps/shoppingmall/products/entity/brand/CosmeticBrand.hbm.xml

Looks like hibernate has problem to read the file (wrong name?)...


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 19, 2004 3:11 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
You're mapping the 2 one-to-many mapping to CosmeticProduct in the same brand_id. This is unexpected.

_________________
Emmanuel


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.