Attached are two xml files. One, "dev.xml" is the file used to setup the
databse connection using normal JDBC connections (not using a datasource).

The other, "webrent.xml",  is the mapping file for some persistent objects.
I have a few probs with the Group and GroupRole relationships so there may
be a few tweaks still required. Atleast it should give you some idea though.

Varchar and char are both mapped to java.lang.String. If you use long
strings, you may want to use blob or clob, depending on your database.

The key-generator is used by castor to automatically assign persistent
object identifiers. You can leave these out but then you would have to
provide your own.

Good luck,
Bert.

----- Original Message -----
From: <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Saturday, January 19, 2002 9:09 AM
Subject: Re: [castor-dev] mapping.xml


>
>      That's not correct; the dtd does not provide all available values.
As
> an aside, I do read all available documentation before asking questions,
> including the dtd and samples.
>
>      The dtd states" The field type is the proper Java class of the
field's
> value or a short name that maps to a Java class (e.g. integer or
> java.lang.Integer)."
>
>
> To  those familiar with the product, that might mean something.  To
someone
> new to JDBC and Caster, it might not.  I fall into the later category.  To
> try and clarify this I did also look at the sample mapping file.  This
uses
> int and String and Vector I believe, and that's about it.  From this I
> might assume that float is also valid, but what about varchar?  And char?
> How are they used?  I have varchar fields that vary in length from about
16
> to 3072; does that mean they need to be declared differently?  And what if
> one of the fields is auto-genereated by the DB?
>
>
>
>
>
>
>                     Bruce Snyder
>                     <ferret@frii.        To:     [EMAIL PROTECTED]
>                     com>                 cc:
>                                          Subject:     Re: [castor-dev]
mapping.xml
>                     01/18/02
>                     02:16 PM
>                     Please
>                     respond to
>                     castor-dev
>
>
>
>
>
>
> This one time, at band camp, [EMAIL PROTECTED] said:
>
>  >     Does someone have a better example of one of these they could
share?
>  >I'm new to JDBC, and don't understand all of the XML file.  A list of
>  >allowed values for the field values, for example.  A better explanation
/
>  >example of using object relationships.
>
> Timothy,
>
> Please see http://castor.exolab.org/mapping.dtd. This provides
> comments on all available values. Also, see src/examples/jdo/mapping.xml
> for the mapping descriptor for the CastorJDO examples.
>
> Bruce
> --
>
> perl -e 'print unpack("u30","<0G)U8V4\@4VYY9&5R\"F9E<G)E
> =\$\!F<FEI+F-O;0\`\`");'
>
> -----------------------------------------------------------
> If you wish to unsubscribe from this mailing, send mail to
> [EMAIL PROTECTED] with a subject of:
>            unsubscribe castor-dev
>
> -----------------------------------------------------------
> If you wish to unsubscribe from this mailing, send mail to
> [EMAIL PROTECTED] with a subject of:
> unsubscribe castor-dev
<!DOCTYPE databases PUBLIC "-//EXOLAB/Castor JDO Configuration DTD Version 1.0//EN"
                             "/schemas/jdo-conf.dtd">
      
<database name="dev" engine="mysql">
    <driver class-name="org.gjt.mm.mysql.Driver"
            url="jdbc:mysql://localhost/dev">
      <param name="user" value="dev" />
      <param name="password" value="dev" />
    </driver>
    <mapping href="webrent.xml" />
</database>
<!DOCTYPE databases PUBLIC "-//EXOLAB/Castor Mapping DTD Version 1.0//EN"
                           "http://castor.exolab.org/mapping.dtd";>
<mapping>
  		<class name="nz.co.webrent.services.security.entity.WebrentUser"  identity="id"
		key-generator="UUID">
    		<description>Generic Webrent User</description>
    		<map-to table="webrent_user" />
    		<field name="id" type="string" required="true">
      			<sql name="user_id" type="varchar" />
				<xml name="userId" node="attribute" />
    		</field>
    		<field name="email" type="string" required="true">
      			<sql name="email" type="varchar" />
				<xml name="email" node="attribute" />
    		</field>
    		<field name="userName" type="string" required="true">
      			<sql name="user_name" type="varchar" />
				<xml name="user_name" node="attribute" />
    		</field>
    		<field name="password" type="string" required="true">
      			<sql name="password" type="varchar" />
				<xml name="password" node="attribute" />
    		</field>
			<field name="modifiedDate" type="date" >
      			<sql name="modified_date" type="date" />
				<xml name="modifiedDate" node="attribute" />
    		</field>
			<field name="createDate" type="date" >
      			<sql name="create_date" type="date" />
				<xml name="createDate" node="attribute" />
    		</field>
			<field name="pwdModifiedDate" type="date">
      			<sql name="pwd_modified_date" type="date" />
				<xml name="pwdModified" node="attribute" />
    		</field>
			<field name="lastLogin" type="date">
      			<sql name="last_login" type="date" />
				<xml name="lastLogin" node="attribute" />
    		</field>
			<field name="confirmData" type="string">
      			<sql name="confirm_data" type="varchar" />
				<xml name="confirmData" node="attribute" />
    		</field>
			<field name="confirmValue" type="string">
      			<sql name="confirm_value" type="varchar" />
				<xml name="confirmValue" node="attribute" />
    		</field>
			<field name="firstName" type="string">
      			<sql name="first_name" type="varchar" />
				<xml name="firstName" node="attribute" />
    		</field>
			<field name="lastName" type="string">
      			<sql name="last_name" type="varchar" />
				<xml name="lastName" node="attribute" />
    		</field>		
			<field name="accountStatus" type="integer">
      			<sql name="acc_status" type="integer" />
				<xml name="accountStatus" node="attribute" />
    		</field>
			<field name="profileId" type="string">
      			<sql name="profile_id" type="varchar" />
				<xml name="profileId" node="attribute" />
    		</field>
			<field name="profileClazz" type="string">
      			<sql name="profile_class" type="varchar" />
      			<xml name="profileClass" node="attribute" />
   			</field>				
		</class>
		<class name="nz.co.webrent.services.security.entity.WebrentPermission" identity="id"
			key-generator="UUID">
    		<description>Generic Webrent Permission</description>
    		<map-to table="webrent_permission" />    			 
			<field name="id" type="string" required="true">
      		 	<sql name="perm_id" type="varchar" />
				<xml name="id" node="attribute" />
    		</field>
    		<field name="name" type="string" required="true">
      			<sql name="perm_name" type="varchar" />
				<xml name="name" node="attribute" />
    		</field>
    		<field name="description" type="string">
      			<sql name="perm_desc" type="varchar" />
				<xml name="description" node="attribute" />
    		</field>
		</class>
		<class name="nz.co.webrent.services.security.entity.WebrentRole" identity="id"
			key-generator="UUID">
    		<description>Generic Webrent Role</description>
    		<map-to table="webrent_role" />    			 
			<field name="id" type="string" required="true">
      		 	<sql name="role_id" type="varchar" />
				<xml name="id" node="attribute" />
    		</field>
    		<field name="name" type="string" required="true">
      			<sql name="role_name" type="varchar" />
				<xml name="name" node="attribute" />
    		</field>
    		<field name="description" type="string">
      			<sql name="role_desc" type="varchar" />
				<xml name="description" node="attribute" />
    		</field>
    		<field name="permissions" type="nz.co.webrent.services.security.entity.WebrentPermission" 
				required="true" collection="collection" direct="false" lazy="true" 
				set-method="setPermissions" get-method="getAllPermissions">
      		 	<sql name="perm_id" many-table="webrent_role_permission_map" many-key="role_id" />
				<xml name="permissions" node="element" />
    		</field>					 
		</class>			
		<class name="nz.co.webrent.services.security.entity.WebrentGroup" identity="id"
			key-generator="UUID">
    		<description>Generic Webrent Group</description>
    		<map-to table="webrent_group" />    			 
			<field name="id" type="string" required="true">
      			<sql name="group_id" type="varchar" />
				<xml name="id" node="attribute" />
    		</field>
    		<field name="name" type="string" required="true">
      			<sql name="group_name" type="varchar" />
				<xml name="name" node="attribute" />
    		</field>
    		<field name="description" type="string" required="false">
      		 	<sql name="group_desc" type="varchar" />
				<xml name="description" node="attribute" />
    		</field>
			<field name="groupRoles" type="nz.co.webrent.services.security.entity.WebrentGroupRole" 
				required="false" collection="collection" direct="false" lazy="true"
				set-method="setGroupRoles" get-method="getGroupRoles">
      		 	<sql name="grole_id" many-table="webrent_group_grole_map" />
				<xml name="grouproles" node="element" />
    		</field>
		</class>		
		<class name="nz.co.webrent.services.security.entity.WebrentGroupRole" identity="id" 
			depends="nz.co.webrent.services.security.entity.WebrentGroup" key-generator="UUID">
    		<description>Generic Webrent GroupRole</description>
    		<map-to table="webrent_grole" />    	
			<field name="id" type="string" required="true">
      		 	<sql name="grole_id" type="varchar" />
				<xml name="id" node="attribute" />
    		</field>
			<field name="role" type="nz.co.webrent.services.security.entity.WebrentRole" 
				required="true" direct="false">
      		 	<sql name="role_id" />
				<xml name="id" node="element" />
    		</field>
			<field name="users" type="nz.co.webrent.services.security.entity.WebrentUser" 
				required="false" collection="collection" direct="false" lazy="true">
      		 	<sql name="user_id" many-table="webrent_grole_user_map" many-key="grole_id" />
				<xml name="users" node="element" />
    		</field>
		</class>	
</mapping>


Reply via email to