summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPetya Sabeva2012-11-03 18:43:18 (EDT)
committerPetya Sabeva2012-11-03 18:43:18 (EDT)
commit20806341a3d7394a4b9261a84d42936d6dfc4db4 (patch)
treed91a636de5044a00effb291397edde7bd6fa9322
parent952e9b51b1a5347369c2c8e6647d9e10aa011ec2 (diff)
downloadwebtools.dali-20806341a3d7394a4b9261a84d42936d6dfc4db4.zip
webtools.dali-20806341a3d7394a4b9261a84d42936d6dfc4db4.tar.gz
webtools.dali-20806341a3d7394a4b9261a84d42936d6dfc4db4.tar.bz2
Bug 389268 - Creating entities that implement java.io.Serializable
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/JPAEditorUtil.java13
1 files changed, 9 insertions, 4 deletions
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/JPAEditorUtil.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/JPAEditorUtil.java
index b8cb3be..20005df 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/JPAEditorUtil.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/JPAEditorUtil.java
@@ -1033,9 +1033,11 @@ public class JPAEditorUtil {
String mappedSuperclassShortName = mappedSuperclassName
.substring(mappedSuperclassName.lastIndexOf('.') + 1);
String content = "package " + JPADiagramPropertyPage.getDefaultPackage(project) + ";\n\n" //$NON-NLS-1$ //$NON-NLS-2$
+ + "import java.io.Serializable;\n"
+ "import javax.persistence.*;\n\n" //$NON-NLS-1$
+ "@MappedSuperclass \n" //$NON-NLS-1$
- + "public class " + mappedSuperclassShortName + " {\n\n" //$NON-NLS-1$ //$NON-NLS-2$
+ + "public class " + mappedSuperclassShortName + " implements Serializable {\n\n" //$NON-NLS-1$ //$NON-NLS-2$
+ + "private static final long serialVersionUID = 1L;\n"
+ "}"; //$NON-NLS-1$
return createClassInProject(project, folder, mappedSuperclassShortName, content);
}
@@ -1186,12 +1188,13 @@ public class JPAEditorUtil {
boolean fieldBasedAccess = JPADiagramPropertyPage.isAccessFieldBased(project, props);
String classDeclarationStringContent = null;
+ String importSerializable = "";
if (isMappedSuperclassChild) {
String mappedSuperclassShortName = mappedSuperclassName.substring(mappedSuperclassName.lastIndexOf('.') + 1);
classDeclarationStringContent = "public class " + entityShortName + " extends " + mappedSuperclassShortName + " {\n\n"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
} else {
- classDeclarationStringContent = "public class " + entityShortName + " {\n\n"; //$NON-NLS-1$ //$NON-NLS-2$
-
+ classDeclarationStringContent = "public class " + entityShortName + " implements Serializable {\n\n"; //$NON-NLS-1$ //$NON-NLS-2$
+ importSerializable += "import java.io.Serializable;\n";
}
String packageImport = ""; //$NON-NLS-1$
@@ -1206,13 +1209,15 @@ public class JPAEditorUtil {
primaryKeyDeclaration = generatePrimaryKeyDeclaration(fieldBasedAccess, idName);
String content = "package " + JPADiagramPropertyPage.getDefaultPackage(project, props) //$NON-NLS-1$
- + ";\n\n" //$NON-NLS-1$
+ + ";\n\n" //$NON-NLS-1$
+ + importSerializable
+ "import javax.persistence.*;\n" //$NON-NLS-1$
+ packageImport+"\n\n" //$NON-NLS-1$
+ "@Entity \n" //$NON-NLS-1$
+ ((tableName.length() > 0) ? ("@Table(name=\"" //$NON-NLS-1$
+ tableName + "\")\n") : "") //$NON-NLS-1$ //$NON-NLS-2$
+ classDeclarationStringContent
+ + "private static final long serialVersionUID = 1L;\n"
+ primaryKeyDeclaration
+"}"; //$NON-NLS-1$