You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openjpa.apache.org by "Roberto Cortez (JIRA)" <ji...@apache.org> on 2014/12/30 02:52:13 UTC
[jira] [Commented] (OPENJPA-2554) JPA 2.1 - Schema Generation
[ https://issues.apache.org/jira/browse/OPENJPA-2554?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14260664#comment-14260664 ]
Roberto Cortez commented on OPENJPA-2554:
-----------------------------------------
To support the Schema Generation specified in JPA 2.1:
Add relevant properties to <b>org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl</b>:
{code:java}
public IntValue databaseAction;
...
databaseAction = addInt("javax.persistence.schema-generation.database.action");
aliases = new String[] {
"none", String.valueOf(SchemaGeneration.NONE),
"create", String.valueOf(SchemaGeneration.CREATE),
"drop-and-create", String.valueOf(SchemaGeneration.DROP_AND_CREATE),
"drop", String.valueOf(SchemaGeneration.DROP)
};
databaseAction.setAliases(aliases);
databaseAction.setDefault(aliases[0]);
databaseAction.setAliasListComprehensive(true);
{code}
And map the new properties to a SchemaTool command in org.apache.openjpa.jdbc.kernel.JDBCBrokerFactory like this:
{code:java}
private void schemaGenerationToSynchronizeMappings(JDBCConfiguration conf) {
if (conf.getDatabaseAction() != null) {
if (conf.getDatabaseActionConstant() == SchemaGeneration.DROP_AND_CREATE) {
conf.setSynchronizeMappings("buildSchema(ForeignKeys=true,SchemaAction='drop,add')");
}
}
}
{code}
Am I following the right path here? Any others suggestions? SchemaTool is probably going to need a way to execute SQL scripts.
> JPA 2.1 - Schema Generation
> ---------------------------
>
> Key: OPENJPA-2554
> URL: https://issues.apache.org/jira/browse/OPENJPA-2554
> Project: OpenJPA
> Issue Type: New Feature
> Components: sql
> Affects Versions: 2.3.0
> Reporter: Roberto Cortez
> Priority: Blocker
> Labels: jpa21
>
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)