Author: dgeraskov
Date: 2009-05-25 06:22:39 -0400 (Mon, 25 May 2009)
New Revision: 15484
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateJpaFactory.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/HibernatePersistenceUnit.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaEntity.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/JavaGenericGeneratorImpl.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-3507
Added duplication generator check for Entity's Id
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateJpaFactory.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateJpaFactory.java 2009-05-25
08:06:27 UTC (rev 15483)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateJpaFactory.java 2009-05-25
10:22:39 UTC (rev 15484)
@@ -11,7 +11,9 @@
package org.jboss.tools.hibernate.jpt.core.internal;
import org.eclipse.jpt.core.context.java.JavaEntity;
+import org.eclipse.jpt.core.context.java.JavaIdMapping;
import org.eclipse.jpt.core.context.java.JavaJpaContextNode;
+import org.eclipse.jpt.core.context.java.JavaPersistentAttribute;
import org.eclipse.jpt.core.context.java.JavaPersistentType;
import org.eclipse.jpt.core.context.persistence.Persistence;
import org.eclipse.jpt.core.context.persistence.PersistenceUnit;
@@ -19,6 +21,7 @@
import org.eclipse.jpt.core.resource.persistence.XmlPersistenceUnit;
import org.jboss.tools.hibernate.jpt.core.internal.context.HibernatePersistenceUnit;
import org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateJavaEntity;
+import org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateJavaIdMapping;
import org.jboss.tools.hibernate.jpt.core.internal.context.java.JavaGenericGenerator;
import
org.jboss.tools.hibernate.jpt.core.internal.context.java.JavaGenericGeneratorImpl;
@@ -40,6 +43,14 @@
return new HibernateJavaEntity(parent);
}
+ /* (non-Javadoc)
+ * @see
org.eclipse.jpt.core.internal.platform.GenericJpaFactory#buildJavaIdMapping(org.eclipse.jpt.core.context.java.JavaPersistentAttribute)
+ */
+ @Override
+ public JavaIdMapping buildJavaIdMapping(JavaPersistentAttribute parent) {
+ return new HibernateJavaIdMapping(parent);
+ }
+
public JavaGenericGenerator buildJavaGenericGenerator(JavaJpaContextNode parent) {
return new JavaGenericGeneratorImpl(parent);
}
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/HibernatePersistenceUnit.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/HibernatePersistenceUnit.java 2009-05-25
08:06:27 UTC (rev 15483)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/HibernatePersistenceUnit.java 2009-05-25
10:22:39 UTC (rev 15484)
@@ -12,30 +12,19 @@
import java.io.File;
import java.util.List;
-import java.util.ListIterator;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
-import org.eclipse.jpt.core.JpaProject;
-import org.eclipse.jpt.core.context.java.JavaPersistentAttribute;
-import org.eclipse.jpt.core.context.java.JavaPersistentType;
-import org.eclipse.jpt.core.context.persistence.ClassRef;
import org.eclipse.jpt.core.context.persistence.Persistence;
import org.eclipse.jpt.core.internal.context.persistence.GenericPersistenceUnit;
-import org.eclipse.jpt.core.resource.java.JavaResourceNode;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType;
import org.eclipse.jpt.core.resource.persistence.XmlPersistenceUnit;
-import org.eclipse.jpt.utility.internal.CollectionTools;
import org.eclipse.wst.validation.internal.core.Message;
import org.eclipse.wst.validation.internal.provisional.core.IMessage;
import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-import org.jboss.tools.hibernate.jpt.core.internal.HibernateJpaFactory;
import
org.jboss.tools.hibernate.jpt.core.internal.context.basic.BasicHibernateProperties;
import org.jboss.tools.hibernate.jpt.core.internal.context.basic.Hibernate;
-import
org.jboss.tools.hibernate.jpt.core.internal.context.java.GenericGeneratorAnnotation;
/**
* @author Dmitry Geraskov
@@ -54,7 +43,6 @@
public HibernatePersistenceUnit(Persistence parent,
XmlPersistenceUnit persistenceUnit) {
super(parent, persistenceUnit);
- updateGenericGenerators();
this.hibernateProperties = new HibernateJpaProperties(this);
}
@@ -96,53 +84,7 @@
}
}
}
-
- /* (non-Javadoc)
- * @see
org.eclipse.jpt.core.internal.context.persistence.GenericPersistenceUnit#update(org.eclipse.jpt.core.resource.persistence.XmlPersistenceUnit)
- */
- @Override
- public void update(XmlPersistenceUnit persistenceUnit) {
- super.update(persistenceUnit);
- updateGenericGenerators();
- this.fireListChanged(GENERATORS_LIST);
- }
-
-
- protected void updateGenericGenerators(){
- JpaProject project = getJpaProject();
-
- for (ClassRef classRef : CollectionTools.iterable(classRefs())) {
- String annotClass = classRef.getClassName();
- JavaPersistentType type = classRef.getJavaPersistentType();
- JavaResourcePersistentType jrpt = project.getJavaResourcePersistentType(annotClass);
- if (jrpt != null){
- GenericGeneratorAnnotation annotation = null;
- JavaResourceNode jrn = jrpt.getSupportingAnnotation(GENERIC_GENERATOR);
- if (jrn instanceof GenericGeneratorAnnotation) {
- annotation = (GenericGeneratorAnnotation)jrn;
- }
- if (annotation != null) {
- addGenerator(((HibernateJpaFactory)getJpaFactory()).buildJavaGenericGenerator(type));
- }
- ListIterator<JavaPersistentAttribute> typeAttrs = type.attributes();
- for (JavaPersistentAttribute persAttr : CollectionTools.iterable(typeAttrs)) {
- if (persAttr.getSpecifiedMapping() == null) {
- continue;
- }
- JavaResourcePersistentAttribute jrpa = persAttr.getResourcePersistentAttribute();
- jrn = jrpa.getSupportingAnnotation(GENERIC_GENERATOR);
- if (jrn instanceof GenericGeneratorAnnotation) {
- annotation = (GenericGeneratorAnnotation)jrn;
- }
- if (annotation != null) {
- addGenerator(((HibernateJpaFactory)getJpaFactory()).buildJavaGenericGenerator(type));
- }
- }
- }
- }
- }
-
/**
* Hack class needed to make JPA/Validation API pick up our classloader instead of its
own.
*
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaEntity.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaEntity.java 2009-05-25
08:06:27 UTC (rev 15483)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaEntity.java 2009-05-25
10:22:39 UTC (rev 15484)
@@ -16,7 +16,7 @@
import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jpt.core.context.java.JavaGenerator;
import org.eclipse.jpt.core.context.java.JavaPersistentType;
-import org.eclipse.jpt.core.internal.context.java.AbstractJavaEntity;
+import org.eclipse.jpt.core.internal.context.java.GenericJavaEntity;
import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType;
import org.eclipse.jpt.utility.Filter;
import org.eclipse.jpt.utility.internal.iterators.CompositeIterator;
@@ -28,7 +28,7 @@
*
*/
@SuppressWarnings("restriction")
-public class HibernateJavaEntity extends AbstractJavaEntity implements
GenericGeneratorHolder {
+public class HibernateJavaEntity extends GenericJavaEntity implements
GenericGeneratorHolder {
protected JavaGenericGenerator genericGenerator;
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/JavaGenericGeneratorImpl.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/JavaGenericGeneratorImpl.java 2009-05-25
08:06:27 UTC (rev 15483)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/JavaGenericGeneratorImpl.java 2009-05-25
10:22:39 UTC (rev 15484)
@@ -62,7 +62,7 @@
this.setSpecifiedInitialValue_(generator.getInitialValue());
this.setSpecifiedAllocationSize_(generator.getAllocationSize());
this.setSpecifiedStrategy_(generator.getStrategy());
- //getPersistenceUnit().addGenerator(this);
+ this.getPersistenceUnit().addGenerator(this);
}
public void setName(String name) {