This is sometimes useful to share common properties through a technical or a business
superclass without including it as a regular mapped entity (ie no specific table for
this entity). For that purpose you can map them as @MappedSuperclass.


连接池: c3p0   log: slf4j


典型mapping xml (Event.hbm.xml):

<hibernate-mapping package=”org.hibernate.tutorial.domain”>
<class name=”Event” table=”EVENTS”>
<id name=”id” column=”EVENT_ID”>
<generator class=”native”/>
<property name=”date” type=”timestamp” column=”EVENT_DATE”/>
<property name=”title”/>

以上文件需要加入到Hibernate 配置文件中 <mappingresource=”org/hibernate/tutorial/domain/Event.hbm.xml”/>



<set name=”events” table=”PERSON_EVENT”>
<key column=”PERSON_ID”/>
<many-to-many column=”EVENT_ID” class=”Event”/>



Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s