Skip to content

Improved support for OpenJPA persistence units. #8370

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
import java.util.Collections;
import java.util.Map;
import org.netbeans.modules.j2ee.persistence.dd.common.Persistence;
import static org.netbeans.modules.j2ee.persistence.dd.common.PersistenceUnit.JAKARTA_NAMESPACE;
import static org.netbeans.modules.j2ee.persistence.dd.common.PersistenceUnit.JAVAX_NAMESPACE;
import org.openide.util.NbBundle;

/**
Expand Down Expand Up @@ -69,26 +71,44 @@ public String getAnnotationProcessor() {

@Override
public String getTableGenerationPropertyName() {
return getVersion() != null &&
(Persistence.VERSION_2_1.equals(getVersion()) || Persistence.VERSION_2_2.equals(getVersion()))
? super.getTableGenerationPropertyName()
: "openjpa.jdbc.SynchronizeMappings";//NOI18N
String result = (getVersion() != null &&
(Persistence.VERSION_2_1.equals(getVersion()) || Persistence.VERSION_2_2.equals(getVersion())
|| Persistence.VERSION_3_0.equals(getVersion()) || Persistence.VERSION_3_1.equals(getVersion())))
? super.getTableGenerationPropertyName()
: "openjpa.jdbc.SynchronizeMappings";//NOI18N
if (getVersion() != null &&
(Persistence.VERSION_3_0.equals(getVersion()) || Persistence.VERSION_3_1.equals(getVersion()))) {
result = result.replace(JAVAX_NAMESPACE, JAKARTA_NAMESPACE);
}
return result;
}

@Override
public String getTableGenerationDropCreateValue() {
return getVersion() != null &&
(Persistence.VERSION_2_1.equals(getVersion()) || Persistence.VERSION_2_2.equals(getVersion()))
? super.getTableGenerationDropCreateValue()
: "buildSchema(SchemaAction='add,deleteTableContents',ForeignKeys=true)";//NOI18N
String result = (getVersion() != null &&
(Persistence.VERSION_2_1.equals(getVersion()) || Persistence.VERSION_2_2.equals(getVersion())
|| Persistence.VERSION_3_0.equals(getVersion()) || Persistence.VERSION_3_1.equals(getVersion())))
? super.getTableGenerationDropCreateValue()
: "buildSchema(SchemaAction='add,deleteTableContents',ForeignKeys=true)";//NOI18N
if (getVersion() != null &&
(Persistence.VERSION_3_0.equals(getVersion()) || Persistence.VERSION_3_1.equals(getVersion()))) {
result = result.replace(JAVAX_NAMESPACE, JAKARTA_NAMESPACE);
}
return result;
}

@Override
public String getTableGenerationCreateValue() {
return getVersion() != null &&
(Persistence.VERSION_2_1.equals(getVersion()) || Persistence.VERSION_2_2.equals(getVersion()))
? super.getTableGenerationCreateValue()
: "buildSchema(ForeignKeys=true)";//NOI18N
String result = (getVersion() != null &&
(Persistence.VERSION_2_1.equals(getVersion()) || Persistence.VERSION_2_2.equals(getVersion())
|| Persistence.VERSION_3_0.equals(getVersion()) || Persistence.VERSION_3_1.equals(getVersion())))
? super.getTableGenerationCreateValue()
: "buildSchema(ForeignKeys=true)";//NOI18N
if (getVersion() != null &&
(Persistence.VERSION_3_0.equals(getVersion()) || Persistence.VERSION_3_1.equals(getVersion()))) {
result = result.replace(JAVAX_NAMESPACE, JAKARTA_NAMESPACE);
}
return result;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ public class ProviderUtil {
public static final Provider OPENJPA_PROVIDER2_0 = new OpenJPAProvider(Persistence.VERSION_2_0);
public static final Provider OPENJPA_PROVIDER2_1 = new OpenJPAProvider(Persistence.VERSION_2_1);
public static final Provider OPENJPA_PROVIDER2_2 = new OpenJPAProvider(Persistence.VERSION_2_2);
public static final Provider OPENJPA_PROVIDER3_0 = new OpenJPAProvider(Persistence.VERSION_3_0);
public static final Provider OPENJPA_PROVIDER3_1 = new OpenJPAProvider(Persistence.VERSION_3_1);
public static final Provider DEFAULT_PROVIDER = new DefaultProvider();
public static final Provider DEFAULT_PROVIDER2_0 = new DefaultProvider(Persistence.VERSION_2_0);
public static final Provider DEFAULT_PROVIDER2_1 = new DefaultProvider(Persistence.VERSION_2_1);
Expand Down Expand Up @@ -1042,9 +1044,11 @@ public static Provider[] getAllProviders() {
DATANUCLEUS_PROVIDER3_1,
ECLIPSELINK_PROVIDER3_1,
HIBERNATE_PROVIDER3_1,
OPENJPA_PROVIDER3_1,
DATANUCLEUS_PROVIDER3_0,
ECLIPSELINK_PROVIDER3_0,
HIBERNATE_PROVIDER3_0,
OPENJPA_PROVIDER3_0,
DATANUCLEUS_PROVIDER2_2,
ECLIPSELINK_PROVIDER2_2,
HIBERNATE_PROVIDER2_2,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,13 @@ public class PersistenceCfgProperties {
//OpenJPA JPA 2.2 (initially just copy of 2.1)
possiblePropertyValues.put(ProviderUtil.OPENJPA_PROVIDER2_2, new HashMap<String, String[]>());
possiblePropertyValues.get(ProviderUtil.OPENJPA_PROVIDER2_2).putAll(possiblePropertyValues.get(ProviderUtil.OPENJPA_PROVIDER2_1));
//OpenJPA JPA 3.0 (initially just copy of 2.1)
possiblePropertyValues.put(ProviderUtil.OPENJPA_PROVIDER3_0, new HashMap<String, String[]>());
possiblePropertyValues.get(ProviderUtil.OPENJPA_PROVIDER3_0).putAll(possiblePropertyValues.get(ProviderUtil.OPENJPA_PROVIDER2_1));

//OpenJPA JPA 3.1 (initially just copy of 2.1)
possiblePropertyValues.put(ProviderUtil.OPENJPA_PROVIDER3_1, new HashMap<String, String[]>());
possiblePropertyValues.get(ProviderUtil.OPENJPA_PROVIDER3_1).putAll(possiblePropertyValues.get(ProviderUtil.OPENJPA_PROVIDER2_1));

//DataNucleus JPA 1.0
possiblePropertyValues.put(ProviderUtil.DATANUCLEUS_PROVIDER1_0, new HashMap<String, String[]>());
Expand Down Expand Up @@ -673,7 +680,7 @@ public static List<Provider> getProviders(){
ret.add(ProviderUtil.ECLIPSELINK_PROVIDER3_1);
ret.add(ProviderUtil.HIBERNATE_PROVIDER2_2);
ret.add(ProviderUtil.DATANUCLEUS_PROVIDER2_2);
ret.add(ProviderUtil.OPENJPA_PROVIDER2_2);
ret.add(ProviderUtil.OPENJPA_PROVIDER3_1);
return ret;
}

Expand Down