<?xml version="1.0"?>
<bean package="equip2.core.test" class="TestObject1" id="id">
<description>test object 1 - simple bean-style java object with 'id' and 'info' properties (String).
'id' is used as the identity of the object (ie unique primary key) (specified in TestObject1_helper).
</description>
<property name="id" javatype="java.lang.String">
<description>a value - this is used as the identity of this object.</description>
</property>
<property name="info" javatype="java.lang.String">
<description>a value</description>>
</property>
</bean>
Note that the identity and descriptions are optional.
See also ../etc/equip2.core.test.TestObject2.xml
Note that the standard Java primitive & common types (e.g. for use as javatype attribute) are:
boolean |
true/false |
byte |
8 bit signed int |
short |
16 bit signed int |
int |
32 bit signed int |
long |
64 bit signed int |
char |
16 bit signed int and unicode
character |
float |
32 bit float |
double |
64 bit float |
java.lang.String |
Immutable string |
java.util.Vector |
Variable size vector/array of
java.lang.Object references |
java.util.Hashtable |
Map from keys to values (one
value per key) |
java.lang.Boolean |
Boxed boolean (can be null),
subclass of java.lang.Object |
java.lang.Byte |
Boxed byte |
java.lang.Short |
Boxed short |
java.lang.Integer |
Boxed int |
java.lang.Long |
Boxed long |
java.lang.Character |
Boxed char |
java.lang.Float |
Boxed float |
java.lang.Double |
Boxed double |
java equip2.tools.j2se.xsltTransform %EQUIP2_HOME%/etc/bean2java.xsl BEANDEFFILE.xml OUTFILE.javaSee for example, the tools_test ant target which reads ../etc/equip2.core.test.TestObject2.xml and generates ../generated/equip2/core/test/TestObject2.java and ../generated/equip2/core/test/TestObject2_helper.java.
java equip2.tools.j2se.xsltTransform %EQUIP2_HOME%/etc/bean2javahelper.xsl BEANDEFFILE.xml OUTFILE_helper.java
<?xml version="1.0"?>Usage (windows) to create the Hibernate mapping file is (EQUIP2_HOME is equip2 top-level directory):
<bean package="dof2.db" class="Player" id="ID" primarykey="ID" primarykeygenerator="assigned" table="player">
<!-- primarykey is optional; if not specified an internal long-typed primary key
column called 'hibernatekey' is created -->
<!-- primarykeygenerator is optional; default is 'native' (at present)-->
<!-- table is optional; default table name is the same as the class name -->
<description>The player...</description>
<type name="IDType" javatype="java.lang.String" maxlength="20"/>
<!-- a type element is just a type alias for later use -->
<!-- maxlength is optional, and only required in most cases for short strings -->
<property name="ID" type="IDType">
<!-- javatype (and optionally maxlength) can be specified here in the property,
or determined from the identified type element -->
<description>Primary key...</description>
</property>
<property name="nickName" javatype="java.lang.String" maxlength="8">
<!-- like this, for example -->
<description>Player-chosen nickname</description>
</property>
<property name="fullName" javatype="java.lang.String">
<!-- with no specified maxlength Hibernate will use its own default (256?) -->
<description>Player-chosen full name.</description>
</property>
<property name="currentMissions" javatype="java.util.Set" elementtype="IDType">
<!-- set-valued properties will mapped to Hibernate sets. Currently only sets of
primitive types or strings are supported. -->
<description>Set of current mission IDs.</description>
</property>
<linkedclass name="friends" class="Player_Friend" linkproperty="playerID">
<!-- this element will generate a convenience method in the Java bean called
getFriendsTemplate, which will return a Player_Friend template instance
with the playerID property set appropriately, to allow linked (referencing)
instances to be retrieved using a dataspace match() on the template. -->
<description>"Friends" of this player.</description>
</linkedclass>
</bean>
java equip2.tools.j2se.xsltTransform %EQUIP2_HOME%/etc/bean2hibernatehbm.xsl BEANDEFFILE.xml OUTFILE.hbm.xml