i have 2 classes that both refer to the same table in 2 seperate parts of my application. Another words say i have a table
parenttable
ID
Name
Date
In each section of my app i only need 1 of the 2 child tables that refer to sometable's id with a foreignkey. Instead of mapping both of child classes to the parent class, I only mapped one. Then in the other section of my app i created another parentclass with is only mapped the the second child class.
I keep getting an error that duplicate imports exist:
(BELOW COLLECTION IS THE PARENT CLASS)
Caused by: javax.persistence.Persiste
nceExcepti
on: org.hibernate.AnnotationEx
ception: Use of the same entity name twice: Collection
at org.hibernate.ejb.Ejb3Conf
iguration.
configure(
Ejb3Config
uration.ja
va:252)
at org.hibernate.ejb.Hibernat
ePersisten
ce.createE
ntityManag
erFactory(
HibernateP
ersistence
.java:120)
at javax.persistence.Persiste
nce.create
EntityMana
gerFactory
(Persisten
ce.java:51
)
at javax.persistence.Persiste
nce.create
EntityMana
gerFactory
(Persisten
ce.java:33
)
at collectionEntry.Collection
.<clinit>(
Collection
.java:46)
... 23 more
Caused by: org.hibernate.AnnotationEx
ception: Use of the same entity name twice: Collection
at org.hibernate.cfg.annotati
ons.Entity
Binder.bin
dEntity(En
tityBinder
.java:259)
at org.hibernate.cfg.Annotati
onBinder.b
indClass(A
nnotationB
inder.java
:532)
at org.hibernate.cfg.Annotati
onConfigur
ation.proc
essArtifac
tsOfType(A
nnotationC
onfigurati
on.java:45
2)
at org.hibernate.cfg.Annotati
onConfigur
ation.seco
ndPassComp
ile(Annota
tionConfig
uration.ja
va:268)
at org.hibernate.cfg.Configur
ation.buil
dMappings(
Configurat
ion.java:1
115)
at org.hibernate.ejb.Ejb3Conf
iguration.
buildMappi
ngs(Ejb3Co
nfiguratio
n.java:123
3)
at org.hibernate.ejb.EventLis
tenerConfi
gurator.co
nfigure(Ev
entListene
rConfigura
tor.java:1
54)
at org.hibernate.ejb.Ejb3Conf
iguration.
configure(
Ejb3Config
uration.ja
va:869)
at org.hibernate.ejb.Ejb3Conf
iguration.
configure(
Ejb3Config
uration.ja
va:183)
at org.hibernate.ejb.Ejb3Conf
iguration.
configure(
Ejb3Config
uration.ja
va:240)
... 27 more
Caused by: org.hibernate.DuplicateMap
pingExcept
ion: duplicate import: Collection refers to both boothstat_downloader.Colle
ction and collectionEntry.Collection
(try using auto-import="false")
at org.hibernate.cfg.Mappings
.addImport
(Mappings.
java:141)
at org.hibernate.cfg.annotati
ons.Entity
Binder.bin
dEntity(En
tityBinder
.java:252)
... 36 more
The file i am using that describes the persistance unit is:
<persistence-unit name="Booth_StatPU" transaction-type="RESOURCE
_LOCAL">
<provider>org.hibernate.ej
b.Hibernat
ePersisten
ce</provid
er>
<class>boothstat_downloade
r.Collecti
on</class>
<class>boothstat_downloade
r.MoneyDis
play</clas
s>
<properties>
<property name="hibernate.dialect" value="org.hibernate.diale
ct.Firebir
dDialect"/
>
<property name="hibernate.connection
.url" value="jdbc:firebirdsql:wa
rehouse01/
3050:c:\\z
ee03\\data
base\\show
techDB.FDB
"/>
<property name="hibernate.connection
.driver_cl
ass" value="org.firebirdsql.jdb
c.FBDriver
"/>
<property name="hibernate.connection
.password"
value="masterkey"/>
<property name="hibernate.connection
.username"
value="sysdba"/>
<property name="hibernate.cache.prov
ider_class
" value="org.hibernate.cache
.NoCachePr
ovider"/>
</properties>
</persistence-unit>
<persistence-unit name="CollectionEntryPU" transaction-type="RESOURCE
_LOCAL">
<provider>org.hibernate.ej
b.Hibernat
ePersisten
ce</provid
er>
<class>collectionEntry.Col
lection</c
lass>
<class>collectionEntry.Col
lectionCou
nt</class>
<properties>
<property name="hibernate.connection
.url" value="jdbc:firebirdsql:wa
rehouse01/
3050:c:\\z
ee03\\data
base\\show
techDB.FDB
"/>
<property name="hibernate.connection
.driver_cl
ass" value="org.firebirdsql.jdb
c.FBDriver
"/>
<property name="hibernate.connection
.password"
value="masterkey"/>
<property name="hibernate.connection
.username"
value="sysdba"/>
<property name="hibernate.cache.prov
ider_class
" value="org.hibernate.cache
.NoCachePr
ovider"/>
</properties>
</persistence-unit>
is there anyway to make this work so that it does not try to load both Collection Classes?
Start Free Trial