Additional configuration for hbm2ddl script generation
Description
Environment
Activity
David LealMay 29, 2006 at 4:21 PM
Dear Christian,
My suggestion doesn't have to complicate the hbm2dll, because all such definitions the user have to insert via property file, it was just the suggestion, you know better than me what is the best design for this feature. I am aware of that it could be complicated to consider all cases, that is why my suggestion was to at least allow the user to configure if the primary key definition could be generated via ALTER TABLE, so on the generated file will be easier to modify. Now you have to delete the primary key definition on each create table and add an ALTER TABLE for each primary key, with my idea you at least you don't have to delete the primary key definition on the create table.
We use hbm2ddl for getting the schema in oracle syntax because on production we have Oracle but during developer process for the moment we use mysql. Then we process the generated hbm2dll file in order to fix all this details like tablespace, etc.
Please could you be more explicit about your comment no <database-object> (I guess it is a new features on the mapping files), in our particular case we make some minimal modification on the *.hbm file in order to add the oracle sequence during the building process. Probably to add also on this node specific database information would be more complicaded than just modify the database script.
Christian BauerMay 29, 2006 at 3:41 PM
And you probably also haven't seen <database-object>.
Christian BauerMay 29, 2006 at 3:39 PM
1. There are several other issues open already, for improvements to hbm2ddl generation. This is a duplicate.
2. We will never ever add all these options to hbm2ddl. A) It's impossible to cover all possible optimizations and customization of a generated schema. If we add your wishes, the next guy will have others. B) Especially performance optimization is the job of a DBA, who takes the generated schema (file) and manipulates it by hand for deployment in staging and production. Performance optimization settings are not required in a regular development process, for automatically generated schemas. Hibernate supports the most common and simple optimization, with indexes, but that's it.
David LealMay 29, 2006 at 3:33 PM
Max,
I mean to define table space informaion on the create table for the primary key definition, for example I get the following create sentence using hbm2ddl (for oracle configuration):
create table lra.lra_asset_management (
cif varchar2(9) not null,
name varchar2(40),
short_name varchar2(20),
cnmv_code varchar2(6) unique,
primary key (cif)
);
but I would like to add a particular tablespace for the table and for the primery key, so:
create table lra_asset_management (
cif varchar2(9) not null,
name varchar2(40),
short_name varchar2(20),
cnmv_code varchar2(6)
) TABLESPACE BDACCVDO
STORAGE (
INITIAL 960
NEXT 32
);
and for primary key:
ALTER TABLE lra_asset_management
ADD CONSTRAINT PK_LRA_ASSET_MANAGEMENT
PRIMARY KEY (cif)
USING INDEX
TABLESPACE BDACCVIO
PCTFREE 10
INITRANS 2
MAXTRANS 255
STORAGE (
INITIAL 240
NEXT 8
MINEXTENTS 1
MAXEXTENTS 99
PCTINCREASE 0
FREELISTS 1
FREELIST
GROUPS 1
);
so I wanto to have the primary key and table definition on a different tablespace.
My suggestion, is at least to allow on hbm2dll the user can control if the generated script file will use ALTER TABLE, or just primary key definition on the create table statement. The best solution, would be to allow additional information on the configuration property file in order to specify the tablespace info for tables and primary keys, beside additional information, such as create index definition, for example something like this:
lra_asset_management.tablespace = TABLESPACE BDACCVDO
STORAGE (
INITIAL 960
NEXT 32
)
and
PK_LRA_ASSET_MANAGEMENT.tablespace =
USING INDEX
TABLESPACE BDACCVIO
PCTFREE 10
INITRANS 2
MAXTRANS 255
STORAGE (
INITIAL 240
NEXT 8
MINEXTENTS 1
MAXEXTENTS 99
PCTINCREASE 0
FREELISTS 1
FREELIST
GROUPS 1
so the name of the property will be the name of the table name or primary key name, plus tablespace suffix. Another property would be set too for adding create index information, for example:
index = \
CREATE UNIQUE INDEX UQ_1_lra_asset_management \
ON @USER.@lra_asset_management (cnmv_code) \
PCTFREE 10
INITRANS 2
MAXTRANS 255
TABLESPACE @TABLESPACE@
STORAGE (
INITIAL 240
NEXT 8
PCTINCREASE 0
MINEXTENTS 2
MAXEXTENTS 2147483645
);
Max Rydahl AndersenMay 29, 2006 at 11:06 AM
What db does not support defining the primary key when you create the table ?
Just to suggest some additional configuraiton for hbm2ddl script generation, for example:
Adding possibility to configure if the primary key can be defined using alter table instead on the create sentence.
The same for unique index.
Adding possibility for configuring information not provided by the *.hbm files, for example tablespace information. For example on the configuration file, could be defined the tablespace information for each table/index, primary key, etc.
The alter table aproach is better for production database in order to add tablespace information, such configuration can't be set on the create table sentence.
Thanks in advance,
David