"Mickey Mokotov" <[EMAIL PROTECTED]> writes:
actually it does. However, it involves XML. :-)
After you built your schema, you run the "torque:datadtd" task. This will
create a simple DTD for your schema. According to this DTD; you can then
create an XML file which contains your data. This can be loaded into the
database by running the torque:datasql task.
An example:
On Turbine, we have turbine-security-schema which contains the
following table:
--- cut ---
<table name="TURBINE_USER" idMethod="idbroker">
<column name="USER_ID" required="true" primaryKey="true" type="INTEGER"/>
<column name="LOGIN_NAME" required="true" size="64" type="VARCHAR"
javaName="UserName"/>
<column name="PASSWORD_VALUE" required="true" size="16" type="VARCHAR"
javaName="Password"/>
<column name="FIRST_NAME" required="true" size="64" type="VARCHAR"/>
<column name="LAST_NAME" required="true" size="64" type="VARCHAR"/>
<column name="EMAIL" size="64" type="VARCHAR"/>
<column name="CONFIRM_VALUE" size="16" type="VARCHAR" javaName="Confirmed"/>
<column name="MODIFIED" type="TIMESTAMP" size="0"/>
<column name="CREATED" type="TIMESTAMP" size="0" javaName="CreateDate"/>
<column name="LAST_LOGIN" type="TIMESTAMP" size="0"/>
<column name="OBJECTDATA" type="VARBINARY"/>
<unique>
<unique-column name="LOGIN_NAME"/>
</unique>
</table>
--- cut ---
running torque:datadtd creates turbine-security-data.dtd
<!ELEMENT dataset (
TurbineUser|
[...]
)*>
<!ATTLIST dataset
name CDATA #REQUIRED
>
<!ELEMENT TurbineUser EMPTY>
<!ATTLIST TurbineUser
UserId CDATA #REQUIRED
UserName CDATA #REQUIRED
Password CDATA #REQUIRED
FirstName CDATA #REQUIRED
LastName CDATA #REQUIRED
Email CDATA #IMPLIED
Confirmed CDATA #IMPLIED
Modified CDATA #IMPLIED
CreateDate CDATA #IMPLIED
LastLogin CDATA #IMPLIED
Objectdata CDATA #IMPLIED
>
[...]
--- cut ---
According to this DTD, you can now create turbine-security-data.xml
--- cut ---
<?xml version="1.0" encoding="ISO-8859-1" standalone="no" ?>
<!DOCTYPE dataset SYSTEM "file://turbine-security-data.dtd">
[...]
<dataset name="all">
<TurbineUser UserId="1"
UserName="admin"
Password="password"
FirstName=""
LastName="Admin"/>
<TurbineUser UserId="2"
UserName="user"
Password="password"
FirstName=""
LastName="User"/>
[...]
--- cut ---
this turbine-security-data.xml file will create a data SQL file when you
run the torque:datasql and it will be inserted on torque:insert-sql.
I do use this with great success in a number of projects (I do load a country
table with defaults BTW. ;-) )
Regards
Henning
>------=_NextPart_000_000B_01C587CF.C7353460
>Content-Type: text/plain;
> charset="us-ascii"
>Content-Transfer-Encoding: quoted-printable
>Hi guys,
>=20
>Q: I want to fill tables with initial values (for example, one might =
>want to
>have a Country table, and than have this table filled with all the
>countries).
>Does torque schema support adding values for tables?=20
>I'm asking since I'd rather avoid having a 'db-creation-script', rather =
>I'd
>like to keep the schema.xml on cvs and generate the db-creation-script
>whenever I need.
>=20
>--=20
> <http://www.fetchbook.info/> www.FetchBook.Info
>Find the lowest price - Compare more then a hundred book stores in a =
>click.
>=20
>------=_NextPart_000_000B_01C587CF.C7353460--
--
Dipl.-Inf. (Univ.) Henning P. Schmiedehausen INTERMETA GmbH
[EMAIL PROTECTED] +49 9131 50 654 0 http://www.intermeta.de/
RedHat Certified Engineer -- Jakarta Turbine Development -- hero for hire
Linux, Java, perl, Solaris -- Consulting, Training, Development
4 - 8 - 15 - 16 - 23 - 42
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]