I like your workaround. I have a similar setup where I develop
locally in MySQL and then need to deploy to Oracle. In my case I have
existing records and so I want my fancy new Appfuse records to start
somewhere out in the 50000 range. Sadly the Hibernate Annotation does
not support initialValue so I needed to create the Sequence in oracle
and then explicitly reference the sequence in my annotation. Not so
nice, since now I can't deploy to MySQL. Would you be so kind as to
post your patch that switches the Sequence generation code based on
dialect! That would be a great head start for me to fix this. ;-)
-D
On Aug 4, 2008, at 11:14 AM, Michael Gasche wrote:
Hi
Thanks for your answer. I've to look more detailed into this. I
wanted to make my app running on MySql and Oracle. Maybe other
people are interesetd into this: I currently made the following
workaround:
I didn't wanted to use one sequence (hibernate_sequence) on Oracle
which leads into strange primary keys for records because one
sequence distribute id's for all entities. I always use the simple
GeneratedValue annotation. I've been patching (I know, its bad) the
Hiberante SequenceGenerator. As soon as the Oracle dialect is
recognized, i prefix the sequence with the table's name (table
'project' --> rename sequence 'hibernate_sequence' to
'project_sequence'). The MySql dialect just uses the common
mechanism. So the annotation is simply '@GeneratedValue(strategy =
GenerationType.AUTO)'.
Maybe there's a better solution to my Oracle-MySql-Combo.
By the way: I just installed a productive version of my application
using AppFuse 2.0.2 + Spring MVC + Oracle 10g + MySql. The learning
curve in the beginning was appropriate (around 1-2 weeks), but this
is with any framework/platform. In my opinion it still was very
worth using AppFuse. The trade off was little when I compare to the
expenses when I have to compose all good open source components
together. So, thanks Matt for that piece of software. Me, my mac and
AppFuse are a good team.
----------------------------------------------
There's still some issues:
1. Project structure:
/
-/core
-/web
I'm not an advanced maven user, but I currently have to have the
same entities in the /core and in the /web project when I'm
installing/generating entities in the core and in the web. Is there
a better project structure/setup?
2. Another thing is when it comes to Oracle and dbunit CLEAN_INSERT:
- It doesn't find the tables for inserting the data, even they have
been just created (This works with MySql). In
this case my own sequences and even the hibernate_sequence exists:
alter table data add constraint FK2EEFAA85CBA8A8 foreign key
(project_id) references project;
alter table data add constraint FK2EEFAAF79DEACC foreign key
(period_id) references period;
alter table issue add constraint FK5FDA8D985CBA8A8 foreign key
(project_id) references project;
alter table project add constraint FKED904B1997986028 foreign key
(account_id) references account;
alter table project add constraint FKED904B19A18FB88 foreign key
(country_id) references country;
alter table project add constraint FKED904B197F7917B foreign key
(project_type_id) references project_type;
alter table reference add constraint FKC8DB3F4B85CBA8A8 foreign key
(project_id) references project;
alter table risk add constraint FK356ACF85CBA8A8 foreign key
(project_id) references project;
alter table schedule add constraint FKD666929785CBA8A8 foreign key
(project_id) references project;
alter table user_role add constraint FK143BF46AF503D155 foreign key
(user_id) references app_user;
alter table user_role add constraint FK143BF46A4FD90D75 foreign key
(role_id) references role;
create sequence hibernate_sequence;
[INFO] [compiler:testCompile]
[INFO] Nothing to compile - all classes are up to date
[INFO] [dbunit:operation {execution: default}]
[INFO]
------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO]
------------------------------------------------------------------------
[INFO] Error executing database operation: CLEAN_INSERT
[INFO]
------------------------------------------------------------------------
[INFO] Trace
org.apache.maven.lifecycle.LifecycleExecutionException: Error
executing database operation: CLEAN_INSERT
at
org
.apache
.maven
.lifecycle
.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:
583)
at
org
.apache
.maven
.lifecycle
.DefaultLifecycleExecutor
.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:499)
at
org
.apache
.maven
.lifecycle
.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:
478)
at
org
.apache
.maven
.lifecycle
.DefaultLifecycleExecutor
.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:330)
at
org
.apache
.maven
.lifecycle
.DefaultLifecycleExecutor
.executeTaskSegments(DefaultLifecycleExecutor.java:291)
at
org
.apache
.maven
.lifecycle
.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:142)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:336)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:129)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:287)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun
.reflect
.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun
.reflect
.DelegatingMethodAccessorImpl
.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:
315)
at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
at
org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
Caused by: org.apache.maven.plugin.MojoExecutionException: Error
executing database operation: CLEAN_INSERT
at
org.codehaus.mojo.dbunit.OperationMojo.execute(OperationMojo.java:110)
at
org
.apache
.maven
.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:
451)
at
org
.apache
.maven
.lifecycle
.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:
558)
... 16 more
Caused by: org.dbunit.dataset.NoSuchTableException: data
at
org
.dbunit
.database.DatabaseDataSet.getTableMetaData(DatabaseDataSet.java:192)
at
org
.dbunit.operation.DeleteAllOperation.execute(DeleteAllOperation.java:
98)
at
org
.dbunit.operation.CompositeOperation.execute(CompositeOperation.java:
67)
at org.dbunit.ant.Operation.execute(Operation.java:183)
at
org.codehaus.mojo.dbunit.OperationMojo.execute(OperationMojo.java:101)
... 18 more
Cheers, Mike
Matt Raible schrieb:
It depends on how you annotate your classes. For the classes that use
a generated identity, it's usually some sort of increment. If you
want
sequences, you'll need to annotate your classes appropriately.
Matt
On Sat, Aug 2, 2008 at 9:10 PM, Michael Gasche <[EMAIL PROTECTED]
> wrote:
Hi
What sequence names will be used for primary keys (id) when running
AppFuse on Oracle. I was not able to run hbm2ddl on Oracle with
AppFuse
2.0.2, so the DB has been setup more or less manually. This seems to
work, but DB sequences are still missing.
The DB configuration is:
<
dbunit
.dataTypeFactoryName>org.dbunit.ext.oracle.OracleDataTypeFactory</
dbunit.dataTypeFactoryName>
<dbunit.schema>SYSTEM</dbunit.schema> <!-- Make sure to
capitalize the schema name -->
<hibernate.dialect>org.hibernate.dialect.Oracle10gDialect</
hibernate.dialect>
<jdbc.groupId>com.oracle</jdbc.groupId>
<jdbc.artifactId>ojdbc14</jdbc.artifactId>
<jdbc.version>10.2.0.2.0</jdbc.version>
<jdbc.driverClassName>oracle.jdbc.driver.OracleDriver</
jdbc.driverClassName>
Thanks. Mike
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]