Mauro Sergio Silva
2003-12-14 00:32:00 UTC
Hi guys.
I'm developing an application using Hibernate 2.1 with MySql and have some
coments about
continuos integration with you. When I tryied to configure my project using
ant xdoclet to export my schema I've noted that it seams that hibernate
doclets doesn't suport the column element inside propertys, so I culd not
custumize my ddl's. After read some chapters of Xdoclet in Action it seams
to be easy do waht I nedd to do so I decide to take a look in hibenate
modules to see how culd i custumize my templates to support the columns tag.
I've got I good surprise to see that there was an hibernate-column.xdt(xdt
is the doclet tamplate file extension) that was patched by Gaving King (I
think..) that was marged in propertys tamplets so I culd use a doclte like
that:
...
@hibernate.property
@hibernate.column name="foo" sql-type="text"
public String getFoo(){
...
to generate this maping (using MySql dialect)
...
<property
name="foo"
type="java.lang.String"
update="true"
insert="true"
<column
name="foo"
sql-type="text"
/>
</property>
...
Greats now I culd use xdoclet to generate my custumized maping and generate
custumized ddl and I ned to do nothing!.
The next step was that I've decide to use uuid.hex as my id generator, and
i've noticed at first that the hibenate.column was marged
only in hibenate.propertys and I changed the hibernate.xdt and
hibernate-column.xdt to marge columns in id tags and generate the columns
atribute
for both the id and property elemenst .I've submited a patch to xdoclet
project ( I dont now how bug free it is, but until now it works nice to me).
As I was using the rc1 of hibernate I've noticed that that schema export
doesnt care about the column elements in id elements and I've decide to
use the final release to make a unit test and patch the code to generate the
type of column used by primary key in the generated script. good surprise
again
the final release was bug free (do nothing again) and generates my id rights
again and I culd use tags like this.
....
@hibenate.id generator-class = "uuid.hext"
@hibernate.column name = "oid" sql-type = "varchar(32)"
public String getOid () {
...
to generate this map ...
<id
name="id"
<column
name="oid"
sql-type="varchar(32)"
/>
<generator class="uuid.hex">
</generator>
</id>
and this script
...
[schemaexport] oid varchar(32) not null,
...
[schemaexport] primary key (oid)
...
Using string.hex was my decision couse its much flexible and I'm thinking
use clusterb (C-JDBC) to cluster my database in future...
...
I hope that it culd be usefull to someone else
Mauro
I'm developing an application using Hibernate 2.1 with MySql and have some
coments about
continuos integration with you. When I tryied to configure my project using
ant xdoclet to export my schema I've noted that it seams that hibernate
doclets doesn't suport the column element inside propertys, so I culd not
custumize my ddl's. After read some chapters of Xdoclet in Action it seams
to be easy do waht I nedd to do so I decide to take a look in hibenate
modules to see how culd i custumize my templates to support the columns tag.
I've got I good surprise to see that there was an hibernate-column.xdt(xdt
is the doclet tamplate file extension) that was patched by Gaving King (I
think..) that was marged in propertys tamplets so I culd use a doclte like
that:
...
@hibernate.property
@hibernate.column name="foo" sql-type="text"
public String getFoo(){
...
to generate this maping (using MySql dialect)
...
<property
name="foo"
type="java.lang.String"
update="true"
insert="true"
<column
name="foo"
sql-type="text"
/>
</property>
...
Greats now I culd use xdoclet to generate my custumized maping and generate
custumized ddl and I ned to do nothing!.
The next step was that I've decide to use uuid.hex as my id generator, and
i've noticed at first that the hibenate.column was marged
only in hibenate.propertys and I changed the hibernate.xdt and
hibernate-column.xdt to marge columns in id tags and generate the columns
atribute
for both the id and property elemenst .I've submited a patch to xdoclet
project ( I dont now how bug free it is, but until now it works nice to me).
As I was using the rc1 of hibernate I've noticed that that schema export
doesnt care about the column elements in id elements and I've decide to
use the final release to make a unit test and patch the code to generate the
type of column used by primary key in the generated script. good surprise
again
the final release was bug free (do nothing again) and generates my id rights
again and I culd use tags like this.
....
@hibenate.id generator-class = "uuid.hext"
@hibernate.column name = "oid" sql-type = "varchar(32)"
public String getOid () {
...
to generate this map ...
<id
name="id"
<column
name="oid"
sql-type="varchar(32)"
/>
<generator class="uuid.hex">
</generator>
</id>
and this script
...
[schemaexport] oid varchar(32) not null,
...
[schemaexport] primary key (oid)
...
Using string.hex was my decision couse its much flexible and I'm thinking
use clusterb (C-JDBC) to cluster my database in future...
...
I hope that it culd be usefull to someone else
Mauro