-
1. Re: EnverHibernateToolTask generate invalide oracle table na
adamw May 2, 2008 3:43 AM (in response to liuxiaodu)Hello,
I don't have much time today (may holidays, time to leave the computer for a while :) ), but I think the best thing would be if you:
* downloaded the development source package
* edited the method org.jboss.envers.configuration.VersionsEntitiesConfiguration.getDefault()
* build a package using "ant dist", the result will be in the dist category
This of course will be configurable later :)
Adam -
2. Re: EnverHibernateToolTask generate invalide oracle table na
awhitford May 4, 2008 2:32 PM (in response to liuxiaodu)I was hoping that Envers could interrogate the DatabaseMetaData or Dialect to validate if a leading underscore is acceptable, but I can't find any such method.
To Adam's point, I guess the best solution is to make the prefix for the additional revision columns configurable. The default could be "_", but then one could override it to be something like "ENVERS_" to make it work in Oracle. The key, though, is to make the prefix configurable at the persistence unit level or something because I don't want to have to repeat something like 'prefix="ENVERS_"' for every single @Versioned annotation.
I look forward to the updated release. -
3. Re: EnverHibernateToolTask generate invalide oracle table na
awhitford May 10, 2008 1:08 PM (in response to liuxiaodu)Thank you for adding the Generated Tables documentation.
I would like to see the ability to override some default string literals using the persistence.xml, so something like:<persistence-unit name="myPersitenceUnit"> <provider>org.hibernate.ejb.HibernatePersistence</provider> <jta-data-source>java:/myDatasource</jta-data-source> <properties> <property name="hibernate.ejb.naming_strategy" value="org.hibernate.cfg.ImprovedNamingStrategy"/> <property name="envers.version_table_suffix" value="_V"/> <property name="envers.version_column_prefix" value="V_"/> <property name="envers.revisions_info_table_name" value="V_REVISIONS_INFO"/> </properties> </persistence-unit>
For example, the "_version" table suffix. In Oracle, there is a 30 character object name identifier limit. With that suffix, I can only use 22 characters for my Oracle table name. If I could change the suffix to be "_V", I would get up to 28 characters. I know I can use the @VersionsTable annotation, but I would prefer to avoid the extra annotation for every @Versioned class (the DRY principle).
The "_revisions_info" table has the same problem as the version columns in that Oracle doesn't accept the preceding underscore.
Oracle's limited object identifer name rules are frustrating, but it is a popular corporate standard.
(Note that I think the persistence.xml file is a good logical place to define these settings, but I am open to alternatives. I simply want to stress that I want to be able to specify these things centrally in one place rather than adding extra annotations to each @Versioned class.)
Thanks for your help. I look forward to the updates! -
4. Re: EnverHibernateToolTask generate invalide oracle table na
adamw May 13, 2008 3:36 AM (in response to liuxiaodu)Hello,
that's exactly how I wanted to make these properties settable :). So if it's two of us, it must be right ;)
One question, though: you can already set the name of the versions table, as well the names of it fields, using an (almost empty) entity annotated with @RevisionEntity (see http://www.jboss.org/envers/revision_log.html). Do you think the name of the versins table should be configurable both using properties and using @RervisionEntity?
I'll hope I'll have time to implement it by next week.
--
Adam -
5. Re: EnverHibernateToolTask generate invalide oracle table na
liuxiaodu May 13, 2008 10:42 AM (in response to liuxiaodu)Thanks for your help always.
I think what we are asking is the revision related fields in the *_versions table which are generated from your code. If we have option to name those fields, we can overcome the oracle limitation.
Thanks a lot.
Louie -
6. Re: EnverHibernateToolTask generate invalid oracle table nam
awhitford May 17, 2008 2:47 PM (in response to liuxiaodu)"adamw" wrote:
Hello,
One question, though: you can already set the name of the versions table, as well the names of it fields, using an (almost empty) entity annotated with @RevisionEntity (see http://www.jboss.org/envers/revision_log.html). Do you think the name of the versins table should be configurable both using properties and using @RervisionEntity?
One problem is that if we use the @RevisionsEntity mechanism, the "_revisions_info" table does not get skipped when running hbm2ddl -- that is a problem for us because the identifier violates Oracle's naming rules, so we can't execute the generated DDL... Basically, we would like to see the default _revisions_info table skipped IF a @RevisionsEntity exists. Alternatively, we simply need a way to override the "_revision_info" table name (hence the properties suggestion).
I know that you offer the feature whereby we can override the version table name using @VersionedTable. That is a great feature to have, but I would prefer to use that sparingly, not every time. Hence my suggestion to specify a property that overrides the default version table suffix.
Finally, we need a way to override the names for the the version columns (_version_id, _version, _version_type) -- or at least the prefix (as I suggested above) because Oracle doesn't like the preceding underscore.
In the mean time, we have had to modify your source code (as you suggested) to get this to work with Oracle. I am HOPING that with the next version that is released, we will have these configurable so that we don't need to create a custom version. -
7. Re: EnverHibernateToolTask generate invalide oracle table na
adamw May 19, 2008 5:18 AM (in response to liuxiaodu)Hello,
I've uploaded a new version
(http://www.jboss.org/envers/downloads/development),
which has all the names mentioned above configurable.
For details, see
http://www.jboss.org/envers/configuration.html.
Adam -
8. Re: EnverHibernateToolTask generate invalid oracle table nam
adamw May 19, 2008 5:20 AM (in response to liuxiaodu)"awhitford" wrote:
One problem is that if we use the @RevisionsEntity mechanism, the "_revisions_info" table does not get skipped when running hbm2ddl
It should get skipped, and in my configuration it is skipped. Are you sure the entity annotated with @RevisionEntity is also annotated with @Entity? If yes, what's your configuration?
Adam -
9. Re: EnverHibernateToolTask generate invalid oracle table nam
awhitford May 20, 2008 1:51 AM (in response to liuxiaodu)"adamw" wrote:
"awhitford" wrote:
One problem is that if we use the @RevisionsEntity mechanism, the "_revisions_info" table does not get skipped when running hbm2ddl
It should get skipped, and in my configuration it is skipped. Are you sure the entity annotated with @RevisionEntity is also annotated with @Entity? If yes, what's your configuration?
Adam
In my case, I think the issue is that the @RevisionEntity resides in a dependent jar because of refactoring. -
10. Re: EnverHibernateToolTask generate invalide oracle table na
awhitford May 20, 2008 1:53 AM (in response to liuxiaodu)"adamw" wrote:
I've uploaded a new version
(http://www.jboss.org/envers/downloads/development),
which has all the names mentioned above configurable.
For details, see
http://www.jboss.org/envers/configuration.html.
Thanks Adam! This is very helpful! -
11. Re: EnverHibernateToolTask generate invalide oracle table na
adamw May 21, 2008 4:04 AM (in response to liuxiaodu)Ah, I see. The generation of a default revisions info table is skipped if at the moment of generation, there is an entity on the classpath annotated with @RevisionEntity (and of course @Entity).
But maybe that not always need to be the case, so do you think an extra configuration option:
org.jboss.envers.generateDefaultRevisionInfo
would make sense?
Adam