Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Can't able to insert row in table per concrete class strategy .

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have 4 classes : Reservation, Disc (abstract class), AudioDisc, VideoDisc(both extending Disc Class).









Reservation.hbm.xml



<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">;
<hibernate-mapping>
<class name="tableperconcretesubclass.Reservation" table="DB2ADMIN.RES_Test">
<id name="id" type="integer" column="ID" >
<generator class ="assigned"/>
</id>
<!-- <many-to-one name="disc" class="tableperconcretesubclass.Disc" column="DISC_ID" /> -->
<!-- <one-to-one name="disc" class="tableperconcretesubclass.Disc" /> -->

<property name="description" type="string" column="DESCRIPTION"></property>

<set name="discs" lazy="true" cascade="all" >
<key column="DISC_ID" />
<one-to-many class="tableperconcretesubclass.Disc"/>
</set>
</class>
</hibernate-mapping>



Disc.hbm.xml :



<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">;
<hibernate-mapping>
<class name="tableperconcretesubclass.Disc" abstract="true">
<id name="id" type="integer" column="ID" unsaved-value="0">
<generator class ="sequence"/>
</id>

<union-subclass name="tableperconcretesubclass.AudioDisc" extends="tableperconcretesubclass.Disc" lazy="false" table="DB2ADMIN.AUDIODISC_Test">

<property name="singer" type="string" column="SINGER" />
<property name="numOfSongs" type="int" column="NUM_OF_SONGS"/>
<set name="songs" lazy="true" cascade="all" >
<key column="AUDIODISC_ID" />
<one-to-many class="tableperconcretesubclass.Song"/>
</set>
</union-subclass>
<union-subclass name="tableperconcretesubclass.VideoDisc" extends="tableperconcretesubclass.Disc" lazy="true" table="DB2ADMIN.VIDEODISC_Test">
<property name="director" type="string" column="DIRECTOR" />
<property name="language" type="string" column="LANG"/>
</union-subclass>
</class>
</hibernate-mapping>



Song.hbm.xml :



<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">;
<hibernate-mapping>
<class name="tableperconcretesubclass.Song" table="DB2ADMIN.SONG_Test">
<id name="id" type="integer" column="ID" >
<generator class ="assigned"/>
</id>
<property name="title">
<column name="TITLE" />
</property>

<property name="movie">
<column name="MOVIE" />
</property>

</class>
</hibernate-mapping>





when i am running createEntity() method with property

<property name="hibernate.hbm2ddl.auto">create</property>



i am getting following exception :



I am not getting why it is trying to create DISC table when Disc class is abstract ? am i doing anything wrong ? Can anybody please help me ?

Thanks
 
We must storm this mad man's lab and destroy his villanous bomb! Are you with me tiny ad?
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
    Bookmark Topic Watch Topic
  • New Topic