I'm annotating my DAOs and using hibernate3:hbm2ddl to generate the ddls. Is there a way to annotate the tablespace?
No, there is no way to do it out of the box. I've got around it in the past using the following - rather involved - approach:
@TableSpec
that has tablespace and other necessary attributes.org.hibernate.cfg.Configuration
and override getTableMappings()
to return decorated Table
objects (see below).org.hibernate.mapping.Table
and override sqlCreateString()
and / or sqlAlterStrings()
to append tablespace specification (and additional settings if any).Configuration
object, process all your class files collecting and interpreting your @TableSpec
annotations and invoke Configuration.generateSchemaCreationScript()
or generateSchemaUpdateScript()
to generate actual DDL.As I said, rather involved :-) As an alternative, if ALL your mapped tables use the same tablespace, you can extend Oracle dialect you're using and override getTableTypeString()
to return your tablespace spec. While this is an ugly hack (because tableTypeString's original purpose is to provide MySQL engine type), it works and is certainly a lot faster and easier than above approach.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With