|
Hibernate example source code file (Beings.hbm.xml)
The Hibernate Beings.hbm.xml source code<?xml version="1.0"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"> <!-- This mapping demonstrates (1) use of a class-to-subselect mapping, that allows data defined in other classes to be exposed as a read-only entity (you would do this if you really wanted a view, but didn't or couldn't define one for some reason) This is a "derived entity" mapping. (2) use of <synchronize/> to ensure that auto-flush happens correctly, and that queries against the derived entity do not return stale data --> <hibernate-mapping package="org.hibernate.test.subselect" default-access="field"> <class name="Human" table="humans"> <id name="id" unsaved-value="0" column="bid"> <generator class="hilo"/> </id> <property name="name" not-null="true"/> <property name="sex" not-null="true" update="false"/> <property name="address"/> <property name="heightInches"> <column name="height_centimeters" not-null="true" read="height_centimeters / 2.54E0" write="? * 2.54E0"/> </property> </class> <class name="Alien" table="aliens"> <id name="id" unsaved-value="0" column="bid"> <generator class="hilo"/> </id> <property name="identity" not-null="true" column="ident"/> <property name="planet"/> <property name="species" not-null="true" update="false"/> <property name="heightInches"> <column name="height_centimeters" not-null="true" read="height_centimeters / 2.54E0" write="? * 2.54E0"/> </property> </class> <class name="Being" mutable="false"> <subselect> select bid, name as ident, address as loc, 'human' as species, height_centimeters from humans union select bid, ident, planet as loc, species, height_centimeters from aliens </subselect> <synchronize table="humans"/> <synchronize table="aliens"/> <id name="id" unsaved-value="0" column="bid"> <generator class="native"/> </id> <property name="identity" column="ident"/> <property name="location" column="loc"/> <property name="species"/> <property name="heightInches"> <column name="height_centimeters" not-null="true" read="height_centimeters / 2.54E0"/> </property> </class> </hibernate-mapping> Other Hibernate examples (source code examples)Here is a short list of links related to this Hibernate Beings.hbm.xml source code file: |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.