Author: vyemialyanchyk
Date: 2009-04-23 10:03:12 -0400 (Thu, 23 Apr 2009)
New Revision: 14872
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/JdtUiMessages.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/JdtUiMessages.properties
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/collect/AllEntitiesInfoCollector.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/collect/CollectEntityInfo.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/common/EntityInfo.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/process/AllEntitiesProcessor.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/process/ProcessEntityInfo.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/process/wizard/EntitiesList.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/process/wizard/IHibernateJPAWizardParams.java
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/fields/Country.java
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/fields/DocumentBase.java
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/fields/Foto.java
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/fields/FotoXPerson.java
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/fields/Passport.java
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/fields/Person.java
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/fields/PersonXFoto.java
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/fields/Staff.java
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/fields/Visa.java
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/getters/Country.java
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/getters/FotoXPerson.java
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/getters/Passport.java
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/getters/Person.java
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/getters/PersonXFoto.java
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/getters/Staff.java
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/getters/Visa.java
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/src/org/hibernate/eclipse/jdt/ui/test/JPAMapTest.java
Log:
JBIDE-4229
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/JdtUiMessages.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/JdtUiMessages.java 2009-04-23
13:13:04 UTC (rev 14871)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/JdtUiMessages.java 2009-04-23
14:03:12 UTC (rev 14872)
@@ -6,11 +6,11 @@
private static final String BUNDLE_NAME =
"org.hibernate.eclipse.jdt.ui.internal.JdtUiMessages"; //$NON-NLS-1$
public static String AllEntitiesProcessor_header;
public static String AllEntitiesProcessor_message;
- public static String AllEntitiesProcessor_setup_annotation_generation_preference;
+ public static String AllEntitiesProcessor_preferred_location_annotations;
public static String AllEntitiesProcessor_enable_optimistic_locking;
public static String AllEntitiesProcessor_default_string_length;
- public static String AllEntitiesProcessor_annotate_fields;
- public static String AllEntitiesProcessor_annotate_getters;
+ public static String AllEntitiesProcessor_fields;
+ public static String AllEntitiesProcessor_getters;
public static String AllEntitiesProcessor_auto_select_from_class_preference;
public static String CriteriaQuickAssistProcessor_copy_to_criteria_editor;
public static String CriteriaQuickAssistProcessor_errormessage;
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/JdtUiMessages.properties
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/JdtUiMessages.properties 2009-04-23
13:13:04 UTC (rev 14871)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/JdtUiMessages.properties 2009-04-23
14:03:12 UTC (rev 14872)
@@ -10,11 +10,11 @@
##############################################################################/
AllEntitiesProcessor_header=Hibernate: add JPA annotations
AllEntitiesProcessor_message=Add JPA annotations to the related set of entities. The
following classes will be changed:
-AllEntitiesProcessor_setup_annotation_generation_preference=Setup annotation generation
preference:
+AllEntitiesProcessor_preferred_location_annotations=Preferred location of Annotations:
AllEntitiesProcessor_enable_optimistic_locking=Enable optimistic locking:
AllEntitiesProcessor_default_string_length=Default string length (255 by default):
-AllEntitiesProcessor_annotate_fields=Annotate fields
-AllEntitiesProcessor_annotate_getters=Annotate getters
+AllEntitiesProcessor_fields=Fields
+AllEntitiesProcessor_getters=Getters
AllEntitiesProcessor_auto_select_from_class_preference=Auto select from class preference
CriteriaQuickAssistProcessor_copy_to_criteria_editor=Copy to Criteria Editor
CriteriaQuickAssistProcessor_errormessage= Could not get document contents for
CriteriaQuickAssist
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/collect/AllEntitiesInfoCollector.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/collect/AllEntitiesInfoCollector.java 2009-04-23
13:13:04 UTC (rev 14871)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/collect/AllEntitiesInfoCollector.java 2009-04-23
14:03:12 UTC (rev 14872)
@@ -321,6 +321,21 @@
}
}
+ public boolean hasMappedSuperclassVersion(String parentName) {
+ if (parentName == null) {
+ return false;
+ }
+ EntityInfo entryInfoParent = mapCUs_Info.get(parentName);
+ if (entryInfoParent == null) {
+ return false;
+ }
+ if (entryInfoParent.isAddMappedSuperclassFlag() ||
+ entryInfoParent.hasMappedSuperclassAnnotation()) {
+ return true;
+ }
+ return false;
+ }
+
/**
* process all entities pairs iteratively:
* firstly process pairs with more information about and
@@ -328,6 +343,24 @@
*/
public void resolveRelations() {
Iterator<Map.Entry<String, EntityInfo>> it = null;
+ // resolve parent/child relations
+ // in the case if a child has a @MappedSuperclass parent with version property
+ // we shouldn't add version property to the child
+ it = mapCUs_Info.entrySet().iterator();
+ while (it.hasNext()) {
+ Map.Entry<String, EntityInfo> entry = it.next();
+ EntityInfo entityInfo = entry.getValue();
+ String parentName = entityInfo.getFullyQualifiedParentName();
+ if (hasMappedSuperclassVersion(parentName)) {
+ entityInfo.setAddVersionFlag(false);
+ }
+ else {
+ entityInfo.setAddVersionFlag(true);
+ }
+ entityInfo.updateVersionImport(entityInfo.isAddVersionFlag());
+ }
+ //
+ // resolve connection relations
int fromVariableCounter = 0;
int fromMethodCounter = 0;
// generate RefFieldInfoMap (for simple process)
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/collect/CollectEntityInfo.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/collect/CollectEntityInfo.java 2009-04-23
13:13:04 UTC (rev 14871)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/collect/CollectEntityInfo.java 2009-04-23
14:03:12 UTC (rev 14872)
@@ -46,6 +46,7 @@
import org.hibernate.eclipse.jdt.ui.internal.jpa.common.JPAConst;
import org.hibernate.eclipse.jdt.ui.internal.jpa.common.RefType;
import org.hibernate.eclipse.jdt.ui.internal.jpa.common.Utils;
+import org.hibernate.eclipse.jdt.ui.internal.jpa.common.EntityInfo.FieldGetterType;
/**
* Visitor to collect information about JPA entity.
@@ -175,6 +176,7 @@
}
entityInfo.setAddEntityFlag(false);
entityInfo.setAddMappedSuperclassFlag(false);
+ entityInfo.setHasMappedSuperclassAnnotation(true);
}
}
else if (JPAConst.isAnnotationVersion(fullyQualifiedName)) {
@@ -184,7 +186,7 @@
if (tb == null) {
entityInfo.addRequiredImport(JPAConst.IMPORT_VERSION);
}
- entityInfo.setAddVersionFlag(false);
+ entityInfo.setHasVersionAnnotation(true);
}
}
else if (JPAConst.isAnnotationColumn(fullyQualifiedName) && node instanceof
NormalAnnotation) {
@@ -398,7 +400,7 @@
}
}
// process it as a field declaration
- boolean res = processFieldOrGetter(type, list);
+ boolean res = processFieldOrGetter(type, list, false);
return res;
}
@@ -411,11 +413,28 @@
String name = var.getName().getIdentifier();
list.add(name);
}
- boolean res = processFieldOrGetter(type, list);
+ boolean res = processFieldOrGetter(type, list, true);
return res;
}
+
+ public FieldGetterType updateFieldGetter(FieldGetterType fieldGetter, boolean fieldFlag)
{
+ if (fieldGetter == FieldGetterType.FIELD) {
+ if (!fieldFlag) {
+ fieldGetter = FieldGetterType.FIELD_GETTER;
+ }
+ }
+ else if (fieldGetter == FieldGetterType.GETTER) {
+ if (fieldFlag) {
+ fieldGetter = FieldGetterType.FIELD_GETTER;
+ }
+ }
+ else if (fieldGetter == FieldGetterType.UNDEF) {
+ fieldGetter = fieldFlag ? FieldGetterType.FIELD : FieldGetterType.GETTER;
+ }
+ return fieldGetter;
+ }
- public boolean processFieldOrGetter(Type type, List<String> list) {
+ public boolean processFieldOrGetter(Type type, List<String> list, boolean
fieldFlag) {
if (type == null) {
return false;
}
@@ -427,7 +446,9 @@
while (itVarNames.hasNext()) {
String name = (String)itVarNames.next();
if ("version".equalsIgnoreCase(name)) { //$NON-NLS-1$
- entityInfo.setAddVersionFlag(true);
+ FieldGetterType versionFieldGetter =
+ updateFieldGetter(entityInfo.getVersionFieldGetter(), fieldFlag);
+ entityInfo.setVersionFieldGetter(versionFieldGetter);
}
else {
entityInfo.addPrimaryIdCandidate(name);
@@ -464,7 +485,9 @@
while (itVarNames.hasNext()) {
String name = (String)itVarNames.next();
if ("version".equalsIgnoreCase(name)) { //$NON-NLS-1$
- entityInfo.setAddVersionFlag(true);
+ FieldGetterType versionFieldGetter =
+ updateFieldGetter(entityInfo.getVersionFieldGetter(), fieldFlag);
+ entityInfo.setVersionFieldGetter(versionFieldGetter);
}
else {
entityInfo.addPrimaryIdCandidate(name);
@@ -477,7 +500,9 @@
while (itVarNames.hasNext()) {
String name = (String)itVarNames.next();
if ("version".equalsIgnoreCase(name)) { //$NON-NLS-1$
- entityInfo.setAddVersionFlag(true);
+ FieldGetterType versionFieldGetter =
+ updateFieldGetter(entityInfo.getVersionFieldGetter(), fieldFlag);
+ entityInfo.setVersionFieldGetter(versionFieldGetter);
}
}
}
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/common/EntityInfo.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/common/EntityInfo.java 2009-04-23
13:13:04 UTC (rev 14871)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/common/EntityInfo.java 2009-04-23
14:03:12 UTC (rev 14872)
@@ -58,6 +58,10 @@
*/
protected boolean addMappedSuperclassFlag = false;
/*
+ * if true - "@MappedSuperclass" exist for the entity
+ */
+ protected boolean hasMappedSuperclassAnnotation = false;
+ /*
* existing imports set
*/
protected Set<String> setExistingImports = new TreeSet<String>();
@@ -95,10 +99,39 @@
*/
protected boolean addGeneratedValueFlag = true;
/*
- * if true - add version marker for "version" property
+ * if true - add version marker for "version" field
*/
protected boolean addVersionFlag = false;
+ //
+ public enum FieldGetterType {
+ UNDEF(0),
+ FIELD(1),
+ GETTER(2),
+ FIELD_GETTER(3);
+
+ FieldGetterType(int id) {
+ this.id = id;
+ }
+
+ private int id;
+
+ public int getId() {
+ return id;
+ }
+
+ public static String getClassName() {
+ return FieldGetterType.class.getName();
+ }
+ }
/*
+ * if true - entity has "version" field
+ */
+ protected FieldGetterType versionFieldGetter = FieldGetterType.UNDEF;
+ /*
+ * if true - there is a property with @Version
+ */
+ protected boolean hasVersionAnnotation = false;
+ /*
* define relations between entities
* field id -> RefEntityInfo
*/
@@ -212,12 +245,7 @@
else {
removeRequiredImport(JPAConst.IMPORT_MAPPEDSUPERCLASS);
}
- if (isAddVersionFlag()) {
- addRequiredImport(JPAConst.IMPORT_VERSION);
- }
- else {
- removeRequiredImport(JPAConst.IMPORT_VERSION);
- }
+ updateVersionImport(FieldGetterType.UNDEF != getVersionFieldGetter());
updateColumnAnnotationImport(false);
Iterator<Map.Entry<String, RefEntityInfo>> referencesIt =
getReferences().entrySet().iterator();
@@ -263,6 +291,15 @@
}
}
+ public void updateVersionImport(boolean includeFlag) {
+ if (includeFlag) {
+ addRequiredImport(JPAConst.IMPORT_VERSION);
+ }
+ else {
+ removeRequiredImport(JPAConst.IMPORT_VERSION);
+ }
+ }
+
public void updateColumnAnnotationImport(boolean nonDefault) {
if (isNonColumnAnnotatedStringField() && nonDefault) {
addRequiredImport(JPAConst.IMPORT_COLUMN);
@@ -336,6 +373,14 @@
this.addMappedSuperclassFlag = addMappedSuperclassFlag;
}
+ public boolean hasMappedSuperclassAnnotation() {
+ return hasMappedSuperclassAnnotation;
+ }
+
+ public void setHasMappedSuperclassAnnotation(boolean hasMappedSuperclassAnnotation) {
+ this.hasMappedSuperclassAnnotation = hasMappedSuperclassAnnotation;
+ }
+
public boolean isAddSerializableInterfaceFlag() {
return addSerializableInterfaceFlag;
}
@@ -512,6 +557,22 @@
this.addVersionFlag = addVersionFlag;
}
+ public FieldGetterType getVersionFieldGetter() {
+ return versionFieldGetter;
+ }
+
+ public void setVersionFieldGetter(FieldGetterType versionFieldGetter) {
+ this.versionFieldGetter = versionFieldGetter;
+ }
+
+ public boolean hasVersionAnnotation() {
+ return hasVersionAnnotation;
+ }
+
+ public void setHasVersionAnnotation(boolean hasVersionAnnotation) {
+ this.hasVersionAnnotation = hasVersionAnnotation;
+ }
+
public void addExistingImport(String existingImport) {
setExistingImports.add(existingImport);
}
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/process/AllEntitiesProcessor.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/process/AllEntitiesProcessor.java 2009-04-23
13:13:04 UTC (rev 14871)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/process/AllEntitiesProcessor.java 2009-04-23
14:03:12 UTC (rev 14872)
@@ -64,10 +64,6 @@
public final static String storePropertyName =
"hibernate.jpa.generation.AnnotationStyle.preference"; //$NON-NLS-1$
/**
- * @Column length - default value
- */
- public final static int columnLength = 255;
- /**
* default length for column which corresponds to String field
*/
protected int defaultStrLength = columnLength;
@@ -281,6 +277,7 @@
//
entityInfo.updateColumnAnnotationImport(defaultStrLength != columnLength);
+ entityInfo.updateVersionImport(enableOptLock &&
entityInfo.isAddVersionFlag());
//
ChangeStructure cs = new ChangeStructure();
cs.fullyQualifiedName = fullyQualifiedName;
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/process/ProcessEntityInfo.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/process/ProcessEntityInfo.java 2009-04-23
13:13:04 UTC (rev 14871)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/process/ProcessEntityInfo.java 2009-04-23
14:03:12 UTC (rev 14872)
@@ -18,21 +18,28 @@
import org.eclipse.jdt.core.dom.ASTNode;
import org.eclipse.jdt.core.dom.ASTVisitor;
import org.eclipse.jdt.core.dom.ArrayType;
+import org.eclipse.jdt.core.dom.Assignment;
import org.eclipse.jdt.core.dom.Block;
import org.eclipse.jdt.core.dom.BodyDeclaration;
import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.eclipse.jdt.core.dom.ExpressionStatement;
+import org.eclipse.jdt.core.dom.FieldAccess;
import org.eclipse.jdt.core.dom.FieldDeclaration;
import org.eclipse.jdt.core.dom.ImportDeclaration;
import org.eclipse.jdt.core.dom.MarkerAnnotation;
import org.eclipse.jdt.core.dom.MemberValuePair;
import org.eclipse.jdt.core.dom.MethodDeclaration;
import org.eclipse.jdt.core.dom.Modifier;
+import org.eclipse.jdt.core.dom.Name;
import org.eclipse.jdt.core.dom.NormalAnnotation;
import org.eclipse.jdt.core.dom.NumberLiteral;
import org.eclipse.jdt.core.dom.QualifiedName;
+import org.eclipse.jdt.core.dom.ReturnStatement;
import org.eclipse.jdt.core.dom.SimpleName;
import org.eclipse.jdt.core.dom.SimpleType;
+import org.eclipse.jdt.core.dom.SingleVariableDeclaration;
import org.eclipse.jdt.core.dom.StringLiteral;
+import org.eclipse.jdt.core.dom.ThisExpression;
import org.eclipse.jdt.core.dom.Type;
import org.eclipse.jdt.core.dom.TypeDeclaration;
import org.eclipse.jdt.core.dom.VariableDeclarationFragment;
@@ -46,6 +53,7 @@
import org.hibernate.eclipse.jdt.ui.internal.jpa.common.RefEntityInfo;
import org.hibernate.eclipse.jdt.ui.internal.jpa.common.RefFieldInfo;
import org.hibernate.eclipse.jdt.ui.internal.jpa.common.RefType;
+import org.hibernate.eclipse.jdt.ui.internal.jpa.common.EntityInfo.FieldGetterType;
/**
* Visitor to insert JPA annotations into proper
@@ -204,6 +212,87 @@
lrw.insertBefore(md, insertBeforeNode, null);
}
}
+ if (enableOptLock && entityInfo.isAddVersionFlag() &&
!entityInfo.hasVersionAnnotation()) {
+ // add property "version", add getter/setter getVersion/setVersion,
+ // add annotation for the property or for the getter
+ //
+ final String version = "version"; //$NON-NLS-1$
+ final String versionType = "Integer"; //$NON-NLS-1$
+ //
+ VariableDeclarationFragment vdFragment =
rewriter.getAST().newVariableDeclarationFragment();
+ SimpleName variableName = rewriter.getAST().newSimpleName(version);
+ vdFragment.setName(variableName);
+ FieldDeclaration fieldVersion = rewriter.getAST().newFieldDeclaration(vdFragment);
+ Modifier modifier =
rewriter.getAST().newModifier(Modifier.ModifierKeyword.PROTECTED_KEYWORD);
+ fieldVersion.modifiers().add(modifier);
+ Name typeName = rewriter.getAST().newName(versionType);
+ SimpleType type = rewriter.getAST().newSimpleType(typeName);
+ fieldVersion.setType(type);
+ //
+ MethodDeclaration mdGetter = rewriter.getAST().newMethodDeclaration();
+ modifier = rewriter.getAST().newModifier(Modifier.ModifierKeyword.PUBLIC_KEYWORD);
+ mdGetter.modifiers().add(modifier);
+ Block body = rewriter.getAST().newBlock();
+ ReturnStatement returnVersion = rewriter.getAST().newReturnStatement();
+ variableName = rewriter.getAST().newSimpleName(version);
+ returnVersion.setExpression(variableName);
+ body.statements().add(returnVersion);
+ mdGetter.setBody(body);
+ SimpleName sn = rewriter.getAST().newSimpleName("getVersion");
//$NON-NLS-1$
+ mdGetter.setName(sn);
+ typeName = rewriter.getAST().newName(versionType);
+ type = rewriter.getAST().newSimpleType(typeName);
+ mdGetter.setReturnType2(type);
+ //
+ MethodDeclaration mdSetter = rewriter.getAST().newMethodDeclaration();
+ modifier = rewriter.getAST().newModifier(Modifier.ModifierKeyword.PUBLIC_KEYWORD);
+ mdSetter.modifiers().add(modifier);
+ body = rewriter.getAST().newBlock();
+ Assignment assignment = rewriter.getAST().newAssignment();
+ FieldAccess fieldAccess = rewriter.getAST().newFieldAccess();
+ ThisExpression thisExpression = rewriter.getAST().newThisExpression();
+ fieldAccess.setExpression(thisExpression);
+ variableName = rewriter.getAST().newSimpleName(version);
+ fieldAccess.setName(variableName);
+ assignment.setLeftHandSide(fieldAccess);
+ variableName = rewriter.getAST().newSimpleName(version);
+ assignment.setRightHandSide(variableName);
+ ExpressionStatement expressionStatement =
rewriter.getAST().newExpressionStatement(assignment);
+ body.statements().add(expressionStatement);
+ mdSetter.setBody(body);
+ sn = rewriter.getAST().newSimpleName("setVersion"); //$NON-NLS-1$
+ mdSetter.setName(sn);
+ SingleVariableDeclaration svd = rewriter.getAST().newSingleVariableDeclaration();
+ variableName = rewriter.getAST().newSimpleName(version);
+ svd.setName(variableName);
+ typeName = rewriter.getAST().newName(versionType);
+ type = rewriter.getAST().newSimpleType(typeName);
+ svd.setType(type);
+ mdSetter.parameters().add(svd);
+ //
+ ListRewrite lrw = rewriter.getListRewrite(node,
TypeDeclaration.BODY_DECLARATIONS_PROPERTY);
+ if (entityInfo.getVersionFieldGetter() != FieldGetterType.FIELD &&
+ entityInfo.getVersionFieldGetter() != FieldGetterType.FIELD_GETTER) {
+ lrw.insertLast(fieldVersion, null);
+ }
+ if (entityInfo.getVersionFieldGetter() != FieldGetterType.GETTER &&
+ entityInfo.getVersionFieldGetter() != FieldGetterType.FIELD_GETTER) {
+ lrw.insertLast(mdGetter, null);
+ lrw.insertLast(mdSetter, null);
+ }
+ if (annotationStyle == AnnotStyle.FIELDS) {
+ MarkerAnnotation matd = rewriter.getAST().newMarkerAnnotation();
+ matd.setTypeName(rewriter.getAST().newSimpleName(JPAConst.ANNOTATION_VERSION));
+ lrw = rewriter.getListRewrite(fieldVersion, FieldDeclaration.MODIFIERS2_PROPERTY);
+ lrw.insertFirst(matd, null);
+ }
+ else if (annotationStyle == AnnotStyle.GETTERS) {
+ MarkerAnnotation matd = rewriter.getAST().newMarkerAnnotation();
+ matd.setTypeName(rewriter.getAST().newSimpleName(JPAConst.ANNOTATION_VERSION));
+ lrw = rewriter.getListRewrite(mdGetter, MethodDeclaration.MODIFIERS2_PROPERTY);
+ lrw.insertFirst(matd, null);
+ }
+ }
return true;
}
@@ -254,7 +343,7 @@
lrw.insertFirst(matd, null);
}
}
- if (entityInfo.isAddVersionFlag()) {
+ if (enableOptLock && entityInfo.isAddVersionFlag() &&
!entityInfo.hasVersionAnnotation()) {
Iterator itVarNames = node.fragments().iterator();
boolean addVersionMarker = false;
while (itVarNames.hasNext()) {
@@ -403,7 +492,7 @@
lrw.insertFirst(matd, null);
}
}
- if (entityInfo.isAddVersionFlag()) {
+ if (enableOptLock && entityInfo.isAddVersionFlag() &&
!entityInfo.hasVersionAnnotation()) {
boolean addVersionMarker = false;
if ("version".equals(returnIdentifier)) { //$NON-NLS-1$
addVersionMarker = true;
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/process/wizard/EntitiesList.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/process/wizard/EntitiesList.java 2009-04-23
13:13:04 UTC (rev 14871)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/process/wizard/EntitiesList.java 2009-04-23
14:03:12 UTC (rev 14872)
@@ -123,10 +123,10 @@
combolabel.setLayout(layout);
layout.numColumns = 2;
Label labelChoice = new Label(combolabel, SWT.NULL);
- labelChoice.setText(JdtUiMessages.AllEntitiesProcessor_setup_annotation_generation_preference);
+ labelChoice.setText(JdtUiMessages.AllEntitiesProcessor_preferred_location_annotations);
Combo generateChoice = new Combo(combolabel, SWT.READ_ONLY);
- generateChoice.add(JdtUiMessages.AllEntitiesProcessor_annotate_fields);
- generateChoice.add(JdtUiMessages.AllEntitiesProcessor_annotate_getters);
+ generateChoice.add(JdtUiMessages.AllEntitiesProcessor_fields);
+ generateChoice.add(JdtUiMessages.AllEntitiesProcessor_getters);
generateChoice.add(JdtUiMessages.AllEntitiesProcessor_auto_select_from_class_preference);
int idx = 0;
if (params.getAnnotationStyle().equals(AnnotStyle.FIELDS)) {
@@ -160,24 +160,7 @@
};
generateChoice.addModifyListener(mlGenerateChoice);
-
- /** /
- // TODO: implement enable optimistic locking functionality
- Label labelOptLock = new Label(combolabel, SWT.NULL);
- labelOptLock.setText(JdtUiMessages.AllEntitiesProcessor_enable_optimistic_locking);
- Button checkboxOptLock = new Button(combolabel, SWT.CHECK);
- checkboxOptLock.setSelection(params.getEnableOptLock());
- final Listener mlOptLock = new Listener() {
- public void handleEvent(Event e) {
- params.setEnableOptLock(((Button)e.widget).getSelection());
- params.reCollectModification(data.getBufferManager(), data.getEntities());
- }
-
- };
- checkboxOptLock.addListener(SWT.Selection, mlOptLock);
- /**/
-
Label labelDefaultStrLength = new Label(combolabel, SWT.NULL);
labelDefaultStrLength.setText(JdtUiMessages.AllEntitiesProcessor_default_string_length);
Text textDefaultStrLength = new Text(combolabel, SWT.SINGLE | SWT.BORDER | SWT.TRAIL);
@@ -201,13 +184,33 @@
if (e == null || !(e.getSource() instanceof Text)) {
return;
}
- params.setDefaultStrLength(Integer.valueOf(((Text)e.getSource()).getText()));
+ String str = ((Text)e.getSource()).getText();
+ Integer val = IHibernateJPAWizardParams.columnLength;
+ if (str != null && str.length() > 0) {
+ val = Integer.valueOf(str);
+ }
+ params.setDefaultStrLength(val);
params.reCollectModification(data.getBufferManager(), data.getEntities());
}
};
textDefaultStrLength.addModifyListener(mlDefaultStrLength);
+ // enable optimistic locking functionality
+ Label labelOptLock = new Label(combolabel, SWT.NULL);
+ labelOptLock.setText(JdtUiMessages.AllEntitiesProcessor_enable_optimistic_locking);
+ Button checkboxOptLock = new Button(combolabel, SWT.CHECK);
+ checkboxOptLock.setSelection(params.getEnableOptLock());
+ final Listener mlOptLock = new Listener() {
+
+ public void handleEvent(Event e) {
+ params.setEnableOptLock(((Button)e.widget).getSelection());
+ params.reCollectModification(data.getBufferManager(), data.getEntities());
+ }
+
+ };
+ checkboxOptLock.addListener(SWT.Selection, mlOptLock);
+
setControl(container);
}
}
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/process/wizard/IHibernateJPAWizardParams.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/process/wizard/IHibernateJPAWizardParams.java 2009-04-23
13:13:04 UTC (rev 14871)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/process/wizard/IHibernateJPAWizardParams.java 2009-04-23
14:03:12 UTC (rev 14872)
@@ -22,6 +22,10 @@
* @author Vitali
*/
public interface IHibernateJPAWizardParams {
+ /**
+ * @Column length - default value
+ */
+ public final static int columnLength = 255;
public AnnotStyle getAnnotationStyle();
Modified:
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/fields/Country.java
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/fields/Country.java 2009-04-23
13:13:04 UTC (rev 14871)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/fields/Country.java 2009-04-23
14:03:12 UTC (rev 14872)
@@ -13,6 +13,7 @@
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.ManyToOne;
+import javax.persistence.Version;
@Entity
public class Country {
@@ -34,4 +35,15 @@
return this.name;
}
+ @Version
+ protected Integer version;
+
+ public Integer getVersion() {
+ return version;
+ }
+
+ public void setVersion(Integer version) {
+ this.version = version;
+ }
+
}
Modified:
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/fields/DocumentBase.java
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/fields/DocumentBase.java 2009-04-23
13:13:04 UTC (rev 14871)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/fields/DocumentBase.java 2009-04-23
14:03:12 UTC (rev 14872)
@@ -22,4 +22,12 @@
@Version
protected Integer version;
+
+ public Integer getVersion() {
+ return version;
+ }
+
+ public void setVersion(Integer version) {
+ this.version = version;
+ }
}
Modified:
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/fields/Foto.java
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/fields/Foto.java 2009-04-23
13:13:04 UTC (rev 14871)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/fields/Foto.java 2009-04-23
14:03:12 UTC (rev 14872)
@@ -16,6 +16,7 @@
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.OneToOne;
+import javax.persistence.Version;
@Entity
public class Foto {
Modified:
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/fields/FotoXPerson.java
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/fields/FotoXPerson.java 2009-04-23
13:13:04 UTC (rev 14871)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/fields/FotoXPerson.java 2009-04-23
14:03:12 UTC (rev 14872)
@@ -17,6 +17,7 @@
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
+import javax.persistence.Version;
@Entity
public class FotoXPerson {
@@ -30,4 +31,15 @@
@OneToMany(mappedBy="foto")
protected Set<PersonXFoto> persons = new HashSet<PersonXFoto>(0);
+ @Version
+ protected Integer version;
+
+ public Integer getVersion() {
+ return version;
+ }
+
+ public void setVersion(Integer version) {
+ this.version = version;
+ }
+
}
Modified:
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/fields/Passport.java
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/fields/Passport.java 2009-04-23
13:13:04 UTC (rev 14871)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/fields/Passport.java 2009-04-23
14:03:12 UTC (rev 14872)
@@ -13,6 +13,7 @@
import java.util.Map;
import javax.persistence.Entity;
import javax.persistence.OneToMany;
+import javax.persistence.Version;
@Entity
public class Passport extends Document {
@@ -33,4 +34,15 @@
return visas;
}
+ @Version
+ protected Integer version;
+
+ public Integer getVersion() {
+ return version;
+ }
+
+ public void setVersion(Integer version) {
+ this.version = version;
+ }
+
}
Modified:
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/fields/Person.java
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/fields/Person.java 2009-04-23
13:13:04 UTC (rev 14871)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/fields/Person.java 2009-04-23
14:03:12 UTC (rev 14872)
@@ -17,6 +17,7 @@
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
+import javax.persistence.Version;
@Entity
public class Person {
@@ -56,4 +57,15 @@
this.foto = foto;
}
+ @Version
+ protected Integer version;
+
+ public Integer getVersion() {
+ return version;
+ }
+
+ public void setVersion(Integer version) {
+ this.version = version;
+ }
+
}
Modified:
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/fields/PersonXFoto.java
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/fields/PersonXFoto.java 2009-04-23
13:13:04 UTC (rev 14871)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/fields/PersonXFoto.java 2009-04-23
14:03:12 UTC (rev 14872)
@@ -17,6 +17,7 @@
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
+import javax.persistence.Version;
@Entity
public class PersonXFoto {
@@ -30,4 +31,15 @@
@OneToMany(mappedBy="person")
protected Set<FotoXPerson> fotos = new HashSet<FotoXPerson>(0);
+ @Version
+ protected Integer version;
+
+ public Integer getVersion() {
+ return version;
+ }
+
+ public void setVersion(Integer version) {
+ this.version = version;
+ }
+
}
Modified:
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/fields/Staff.java
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/fields/Staff.java 2009-04-23
13:13:04 UTC (rev 14871)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/fields/Staff.java 2009-04-23
14:03:12 UTC (rev 14872)
@@ -11,6 +11,7 @@
package test.annotated.fields;
import javax.persistence.Entity;
+import javax.persistence.Version;
@Entity
public class Staff extends Document {
@@ -24,4 +25,15 @@
this.code = code;
setDocType((byte)2);
}
+
+ @Version
+ protected Integer version;
+
+ public Integer getVersion() {
+ return version;
+ }
+
+ public void setVersion(Integer version) {
+ this.version = version;
+ }
}
Modified:
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/fields/Visa.java
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/fields/Visa.java 2009-04-23
13:13:04 UTC (rev 14871)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/fields/Visa.java 2009-04-23
14:03:12 UTC (rev 14872)
@@ -12,6 +12,7 @@
import javax.persistence.Entity;
import javax.persistence.OneToMany;
+import javax.persistence.Version;
/**
* @author Dmitry Geraskov
@@ -28,4 +29,15 @@
this.countries = countries;
}
+ @Version
+ protected Integer version;
+
+ public Integer getVersion() {
+ return version;
+ }
+
+ public void setVersion(Integer version) {
+ this.version = version;
+ }
+
}
Modified:
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/getters/Country.java
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/getters/Country.java 2009-04-23
13:13:04 UTC (rev 14871)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/getters/Country.java 2009-04-23
14:03:12 UTC (rev 14872)
@@ -11,6 +11,7 @@
package test.annotated.getters;
import javax.persistence.Entity;
+import javax.persistence.Version;
@Entity
public class Country {
@@ -28,4 +29,15 @@
return this.name;
}
+ protected Integer version;
+
+ @Version
+ public Integer getVersion() {
+ return version;
+ }
+
+ public void setVersion(Integer version) {
+ this.version = version;
+ }
+
}
Modified:
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/getters/FotoXPerson.java
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/getters/FotoXPerson.java 2009-04-23
13:13:04 UTC (rev 14871)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/getters/FotoXPerson.java 2009-04-23
14:03:12 UTC (rev 14872)
@@ -17,6 +17,7 @@
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
+import javax.persistence.Version;
@Entity
public class FotoXPerson {
@@ -53,4 +54,15 @@
public void setPersons(Set<PersonXFoto> persons) {
this.persons = persons;
}
+
+ protected Integer version;
+
+ @Version
+ public Integer getVersion() {
+ return version;
+ }
+
+ public void setVersion(Integer version) {
+ this.version = version;
+ }
}
Modified:
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/getters/Passport.java
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/getters/Passport.java 2009-04-23
13:13:04 UTC (rev 14871)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/getters/Passport.java 2009-04-23
14:03:12 UTC (rev 14872)
@@ -14,6 +14,7 @@
import javax.persistence.Entity;
import javax.persistence.OneToMany;
+import javax.persistence.Version;
@Entity
public class Passport extends Document {
@@ -35,4 +36,14 @@
return visas;
}
+ protected Integer version;
+
+ @Version
+ public Integer getVersion() {
+ return version;
+ }
+
+ public void setVersion(Integer version) {
+ this.version = version;
+ }
}
Modified:
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/getters/Person.java
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/getters/Person.java 2009-04-23
13:13:04 UTC (rev 14871)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/getters/Person.java 2009-04-23
14:03:12 UTC (rev 14872)
@@ -17,6 +17,7 @@
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
+import javax.persistence.Version;
@Entity
public class Person {
@@ -56,4 +57,15 @@
this.foto = foto;
}
+ protected Integer version;
+
+ @Version
+ public Integer getVersion() {
+ return version;
+ }
+
+ public void setVersion(Integer version) {
+ this.version = version;
+ }
+
}
Modified:
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/getters/PersonXFoto.java
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/getters/PersonXFoto.java 2009-04-23
13:13:04 UTC (rev 14871)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/getters/PersonXFoto.java 2009-04-23
14:03:12 UTC (rev 14872)
@@ -17,6 +17,7 @@
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
+import javax.persistence.Version;
@Entity
public class PersonXFoto {
@@ -53,4 +54,15 @@
public void setFotos(Set<FotoXPerson> fotos) {
this.fotos = fotos;
}
+
+ protected Integer version;
+
+ @Version
+ public Integer getVersion() {
+ return version;
+ }
+
+ public void setVersion(Integer version) {
+ this.version = version;
+ }
}
Modified:
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/getters/Staff.java
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/getters/Staff.java 2009-04-23
13:13:04 UTC (rev 14871)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/getters/Staff.java 2009-04-23
14:03:12 UTC (rev 14872)
@@ -11,6 +11,7 @@
package test.annotated.getters;
import javax.persistence.Entity;
+import javax.persistence.Version;
@Entity
public class Staff extends Document {
@@ -24,4 +25,15 @@
this.code = code;
setDocType((byte)2);
}
+
+ protected Integer version;
+
+ @Version
+ public Integer getVersion() {
+ return version;
+ }
+
+ public void setVersion(Integer version) {
+ this.version = version;
+ }
}
Modified:
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/getters/Visa.java
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/getters/Visa.java 2009-04-23
13:13:04 UTC (rev 14871)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/getters/Visa.java 2009-04-23
14:03:12 UTC (rev 14872)
@@ -12,6 +12,7 @@
import javax.persistence.Entity;
import javax.persistence.OneToMany;
+import javax.persistence.Version;
/**
* @author Dmitry Geraskov
@@ -46,4 +47,15 @@
public setCountries(Country[] countries){
this.countries = countries;
}
+
+ protected Integer version;
+
+ @Version
+ public Integer getVersion() {
+ return version;
+ }
+
+ public void setVersion(Integer version) {
+ this.version = version;
+ }
}
Modified:
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/src/org/hibernate/eclipse/jdt/ui/test/JPAMapTest.java
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/src/org/hibernate/eclipse/jdt/ui/test/JPAMapTest.java 2009-04-23
13:13:04 UTC (rev 14871)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/src/org/hibernate/eclipse/jdt/ui/test/JPAMapTest.java 2009-04-23
14:03:12 UTC (rev 14872)
@@ -138,6 +138,7 @@
collector.collect(icu4);
}
collector.resolveRelations();
+ processor.setEnableOptLock(true);
processor.modify(javaProject, collector.getMapCUs_Info(), false);
//
checkItem("DocumentBase"); //$NON-NLS-1$