Author: dgeraskov
Date: 2009-08-21 03:23:56 -0400 (Fri, 21 Aug 2009)
New Revision: 17203
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateJpaProject.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/Messages.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/Messages.properties
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/NamingStrategyMappingTools.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaColumn.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaEntityImpl.java
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/orm/HibernateOrmBasicMapping.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/orm/HibernateOrmEntity.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/orm/HibernateOrmIdMapping.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-4761
Catch NamingStrategy exceptions.
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateJpaProject.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateJpaProject.java 2009-08-21
01:51:09 UTC (rev 17202)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateJpaProject.java 2009-08-21
07:23:56 UTC (rev 17203)
@@ -33,21 +33,21 @@
public HibernateJpaProject(JpaProject.Config config) throws CoreException {
super(config);
}
-
+
public NamingStrategy getNamingStrategy(){
String ccName = getDefaultConsoleConfigurationName();
if (ccName != null || "".equals(ccName)){//$NON-NLS-1$
ConsoleConfiguration cc = KnownConfigurations.getInstance().find(ccName);
if (cc != null){
- if (cc.getConfiguration() != null){
+ if (cc.getConfiguration() != null){
Configuration config = cc.getConfiguration();
- return config.getNamingStrategy();
+ return config.getNamingStrategy();
}
}
}
return null;
}
-
+
public String getDefaultConsoleConfigurationName(){
IScopeContext scope = new ProjectScope(getProject());
Preferences node = scope.getNode("org.hibernate.eclipse.console");
//$NON-NLS-1$
@@ -56,5 +56,5 @@
}
return null;
}
-
+
}
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-08-21
01:51:09 UTC (rev 17202)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/HibernatePersistenceUnit.java 2009-08-21
07:23:56 UTC (rev 17203)
@@ -69,14 +69,14 @@
int resType= res.getType();
if (resType != IResource.FILE) {
Property prop = getProperty(BasicHibernateProperties.HIBERNATE_CONFIG_FILE);
- IMessage message = new LocalMessage(Messages.class.getName(),
IMessage.HIGH_SEVERITY,
+ IMessage message = new LocalMessage(IMessage.HIGH_SEVERITY,
NOT_A_FILE, new String[]{configFile}, getResource());
message.setLineNo(prop.getValidationTextRange().getLineNumber());
messages.add(message);
}
} else {
Property prop = getProperty(BasicHibernateProperties.HIBERNATE_CONFIG_FILE);
- IMessage message = new LocalMessage(Messages.class.getName(),
IMessage.HIGH_SEVERITY,
+ IMessage message = new LocalMessage(IMessage.HIGH_SEVERITY,
CONFIG_FILE_NOT_FOUND, new String[]{configFile}, getResource());
message.setLineNo(prop.getValidationTextRange().getLineNumber());
messages.add(message);
@@ -92,9 +92,9 @@
*/
static public class LocalMessage extends Message {
- public LocalMessage(String name, int severity, String message,
+ public LocalMessage(int severity, String message,
String[] strings, IResource resource) {
- super(name, severity, message, strings, resource);
+ super(Messages.class.getName(), severity, message, strings, resource);
}
}
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/Messages.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/Messages.java 2009-08-21
01:51:09 UTC (rev 17202)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/Messages.java 2009-08-21
07:23:56 UTC (rev 17203)
@@ -26,4 +26,6 @@
String STRATEGY_INTERFACE = "STRATEGY_INTERFACE"; //$NON-NLS-1$
+ String NAMING_STRATEGY_EXCEPTION = "NAMING_STRATEGY_EXCEPTION";
//$NON-NLS-1$
+
}
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/Messages.properties
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/Messages.properties 2009-08-21
01:51:09 UTC (rev 17202)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/Messages.properties 2009-08-21
07:23:56 UTC (rev 17203)
@@ -2,4 +2,5 @@
CONFIG_FILE_NOT_FOUND = Configuration file named \"{0}\" could not be found.
STRATEGY_CLASS_NOT_FOUND = Strategy class \"{0}\" could not be found.
STRATEGY_CANT_BE_EMPTY = Strategy could not be empty.
-STRATEGY_INTERFACE = Strategy class \"{0}\" should implement interface
\"org.hibernate.id.IdentifierGenerator\".
\ No newline at end of file
+STRATEGY_INTERFACE = Strategy class \"{0}\" should implement interface
\"org.hibernate.id.IdentifierGenerator\".
+NAMING_STRATEGY_EXCEPTION = Exception occurred when calling NamingStrategy:
\ No newline at end of file
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/NamingStrategyMappingTools.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/NamingStrategyMappingTools.java 2009-08-21
01:51:09 UTC (rev 17202)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/NamingStrategyMappingTools.java 2009-08-21
07:23:56 UTC (rev 17203)
@@ -17,8 +17,12 @@
import org.eclipse.jpt.core.internal.context.MappingTools;
import org.eclipse.jpt.db.Database;
import org.eclipse.jpt.db.Table;
+import org.eclipse.wst.validation.internal.core.Message;
+import org.eclipse.wst.validation.internal.provisional.core.IMessage;
import org.hibernate.cfg.NamingStrategy;
import org.jboss.tools.hibernate.jpt.core.internal.HibernateJpaProject;
+import org.jboss.tools.hibernate.jpt.core.internal.HibernateJptPlugin;
+import
org.jboss.tools.hibernate.jpt.core.internal.context.HibernatePersistenceUnit.LocalMessage;
/**
* @author Dmitry Geraskov
@@ -44,12 +48,19 @@
if (targetTableName == null) {
return null;
}
- NamingStrategy namingStrategy
=((HibernateJpaProject)targetEntity.getJpaProject()).getNamingStrategy();
- if (namingStrategy != null){
- String name =
namingStrategy.collectionTableName(relationshipMapping.getEntity().getPersistentType().getName(),
- owningTableName, targetEntity.getPersistentType().getName(), targetTableName,
relationshipMapping.getName());
- Table primaryTable = relationshipMapping.getTypeMapping().getPrimaryDbTable();
- return primaryTable.getDatabase().convertNameToIdentifier(name);
+ NamingStrategy ns
=((HibernateJpaProject)targetEntity.getJpaProject()).getNamingStrategy();
+ if (ns != null){
+ try{
+ String name =
ns.collectionTableName(relationshipMapping.getEntity().getPersistentType().getName(),
+ owningTableName, targetEntity.getPersistentType().getName(), targetTableName,
relationshipMapping.getName());
+ Table primaryTable = relationshipMapping.getTypeMapping().getPrimaryDbTable();
+ return primaryTable != null ?
primaryTable.getDatabase().convertNameToIdentifier(name)
+ : name;
+ } catch (Exception e) {
+ Message m = new LocalMessage(IMessage.HIGH_SEVERITY,
+ Messages.NAMING_STRATEGY_EXCEPTION, new String[0], null);
+ HibernateJptPlugin.logException(m.getText(), e);
+ }
}
return owningTableName + '_' + targetTableName;
}
@@ -67,11 +78,17 @@
if (targetTable == null) {
return null;
}
- NamingStrategy namingStrategy =
((HibernateJpaProject)targetEntity.getJpaProject()).getNamingStrategy();
- if (namingStrategy != null){
- String name =
namingStrategy.collectionTableName(relationshipMapping.getEntity().getPersistentType().getName(),
- owningTable.getName(), targetEntity.getPersistentType().getName(),
targetTable.getName(), relationshipMapping.getName());
- return owningTable.getDatabase().convertNameToIdentifier(name);
+ NamingStrategy ns =
((HibernateJpaProject)targetEntity.getJpaProject()).getNamingStrategy();
+ if (ns != null){
+ try {
+ String name =
ns.collectionTableName(relationshipMapping.getEntity().getPersistentType().getName(),
+ owningTable.getName(), targetEntity.getPersistentType().getName(),
targetTable.getName(), relationshipMapping.getName());
+ return owningTable.getDatabase().convertNameToIdentifier(name);
+ } catch (Exception e) {
+ Message m = new LocalMessage(IMessage.HIGH_SEVERITY,
+ Messages.NAMING_STRATEGY_EXCEPTION, new String[0], null);
+ HibernateJptPlugin.logException(m.getText(), e);
+ }
}
String name = owningTable.getName() + '_' + targetTable.getName();
return owningTable.getDatabase().convertNameToIdentifier(name);
@@ -98,18 +115,24 @@
// Column targetColumn = joinColumn.getTargetPrimaryKeyDbColumn();
String targetColumnName = joinColumn.getReferencedColumnName();
- NamingStrategy namingStrategy =
((HibernateJpaProject)targetEntity.getJpaProject()).getNamingStrategy();
- if (namingStrategy != null){
+ NamingStrategy ns =
((HibernateJpaProject)targetEntity.getJpaProject()).getNamingStrategy();
+ if (ns != null){
String logicalTargetColumnName = null;
- if (targetColumnName != null || prefix != null){
- logicalTargetColumnName = namingStrategy.logicalColumnName(targetColumnName,
prefix);
+ try {
+ if (targetColumnName != null || prefix != null){
+ logicalTargetColumnName = ns.logicalColumnName(targetColumnName, prefix);
+ }
+ String name = ns.foreignKeyColumnName(prefix,
+ targetEntity.getPersistentType().getName(),
+ targetEntity.getPrimaryTableName(),
+ logicalTargetColumnName);
+ Table t = targetEntity.getPrimaryDbTable();
+ return t != null ? t.getDatabase().convertNameToIdentifier(name) : name;
+ } catch (Exception e) {
+ Message m = new LocalMessage(IMessage.HIGH_SEVERITY,
+ Messages.NAMING_STRATEGY_EXCEPTION, new String[0], null);
+ HibernateJptPlugin.logException(m.getText(), e);
}
- String name = namingStrategy.foreignKeyColumnName(prefix,
- targetEntity.getPersistentType().getName(),
- targetEntity.getPrimaryTableName(),
- logicalTargetColumnName);
- Table t = targetEntity.getPrimaryDbTable();
- return t != null ? t.getDatabase().convertNameToIdentifier(name) : name;
}
if (prefix == null) {
prefix = targetEntityName;
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaColumn.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaColumn.java 2009-08-21
01:51:09 UTC (rev 17202)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaColumn.java 2009-08-21
07:23:56 UTC (rev 17203)
@@ -3,8 +3,13 @@
import org.eclipse.jpt.core.context.java.JavaColumn;
import org.eclipse.jpt.core.context.java.JavaJpaContextNode;
import org.eclipse.jpt.core.internal.context.java.GenericJavaColumn;
+import org.eclipse.wst.validation.internal.core.Message;
+import org.eclipse.wst.validation.internal.provisional.core.IMessage;
import org.hibernate.cfg.NamingStrategy;
import org.jboss.tools.hibernate.jpt.core.internal.HibernateJpaProject;
+import org.jboss.tools.hibernate.jpt.core.internal.HibernateJptPlugin;
+import org.jboss.tools.hibernate.jpt.core.internal.context.Messages;
+import
org.jboss.tools.hibernate.jpt.core.internal.context.HibernatePersistenceUnit.LocalMessage;
@SuppressWarnings("restriction")
public class HibernateJavaColumn extends GenericJavaColumn {
@@ -20,9 +25,15 @@
@Override
protected String buildDefaultName() {
- NamingStrategy namingStrategy = getJpaProject().getNamingStrategy();
- if (namingStrategy != null && super.buildDefaultName() != null){
- return namingStrategy.propertyToColumnName(super.buildDefaultName());
+ NamingStrategy ns = getJpaProject().getNamingStrategy();
+ if (ns != null && super.buildDefaultName() != null){
+ try {
+ return ns.propertyToColumnName(super.buildDefaultName());
+ } catch (Exception e) {
+ Message m = new LocalMessage(IMessage.HIGH_SEVERITY,
+ Messages.NAMING_STRATEGY_EXCEPTION, new String[0], null);
+ HibernateJptPlugin.logException(m.getText(), e);
+ }
}
return super.buildDefaultName();
}
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaEntityImpl.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaEntityImpl.java 2009-08-21
01:51:09 UTC (rev 17202)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaEntityImpl.java 2009-08-21
07:23:56 UTC (rev 17203)
@@ -33,14 +33,18 @@
import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
import org.eclipse.jpt.utility.internal.iterators.CloneListIterator;
import org.eclipse.jpt.utility.internal.iterators.CompositeIterator;
+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.hibernate.cfg.NamingStrategy;
import org.jboss.tools.hibernate.jpt.core.internal.HibernateJpaFactory;
import org.jboss.tools.hibernate.jpt.core.internal.HibernateJpaProject;
+import org.jboss.tools.hibernate.jpt.core.internal.HibernateJptPlugin;
import org.jboss.tools.hibernate.jpt.core.internal.context.GenericGenerator;
import org.jboss.tools.hibernate.jpt.core.internal.context.HibernateNamedNativeQuery;
import org.jboss.tools.hibernate.jpt.core.internal.context.HibernateNamedQuery;
+import org.jboss.tools.hibernate.jpt.core.internal.context.Messages;
+import
org.jboss.tools.hibernate.jpt.core.internal.context.HibernatePersistenceUnit.LocalMessage;
import org.jboss.tools.hibernate.jpt.core.internal.context.basic.Hibernate;
import
org.jboss.tools.hibernate.jpt.core.internal.resource.java.DiscriminatorFormulaAnnotation;
import
org.jboss.tools.hibernate.jpt.core.internal.resource.java.GenericGeneratorAnnotation;
@@ -466,9 +470,15 @@
}
protected String getResourceDefaultName() {
- NamingStrategy namingStrategy = getJpaProject().getNamingStrategy();
- if (namingStrategy != null){
- return
namingStrategy.classToTableName(javaResourcePersistentType.getQualifiedName());
+ NamingStrategy ns = getJpaProject().getNamingStrategy();
+ if (ns != null){
+ try {
+ return ns.classToTableName(javaResourcePersistentType.getQualifiedName());
+ } catch (Exception e) {
+ Message m = new LocalMessage(IMessage.HIGH_SEVERITY,
+ Messages.NAMING_STRATEGY_EXCEPTION, new String[0], null);
+ HibernateJptPlugin.logException(m.getText(), e);
+ }
}
return javaResourcePersistentType.getName();
}
@@ -513,15 +523,21 @@
}
Entity parentEntity = HibernateJavaEntityImpl.this.getParentEntity();
NamingStrategy ns = HibernateJavaEntityImpl.this.getJpaProject().getNamingStrategy();
- if (ns == null)
- return parentEntity.getPrimaryKeyColumnName();
-
- String name = ns.joinKeyColumnName(parentEntity.getPrimaryKeyColumnName(),
- parentEntity.getPrimaryTableName());
- if (parentEntity.getPrimaryDbTable() != null){
- return parentEntity.getPrimaryDbTable().getDatabase().convertNameToIdentifier(name);
+ if (ns != null) {
+ try {
+ String name = ns.joinKeyColumnName(parentEntity.getPrimaryKeyColumnName(),
+ parentEntity.getPrimaryTableName());
+ if (parentEntity.getPrimaryDbTable() != null){
+ return
parentEntity.getPrimaryDbTable().getDatabase().convertNameToIdentifier(name);
+ }
+ return name ;
+ } catch (Exception e) {
+ Message m = new LocalMessage(IMessage.HIGH_SEVERITY,
+ Messages.NAMING_STRATEGY_EXCEPTION, new String[0], null);
+ HibernateJptPlugin.logException(m.getText(), e);
+ }
}
- return name ;
+ return parentEntity.getPrimaryKeyColumnName();
}
}
}
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-08-21
01:51:09 UTC (rev 17202)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/JavaGenericGeneratorImpl.java 2009-08-21
07:23:56 UTC (rev 17203)
@@ -193,7 +193,7 @@
}
protected IMessage creatErrorMessage(String strmessage, String[] params, int lineNum){
- IMessage message = new LocalMessage(Messages.class.getName(), IMessage.HIGH_SEVERITY,
+ IMessage message = new LocalMessage(IMessage.HIGH_SEVERITY,
strmessage, params, getResource());
message.setLineNo(lineNum);
return message;
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/orm/HibernateOrmBasicMapping.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/orm/HibernateOrmBasicMapping.java 2009-08-21
01:51:09 UTC (rev 17202)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/orm/HibernateOrmBasicMapping.java 2009-08-21
07:23:56 UTC (rev 17203)
@@ -14,8 +14,13 @@
import org.eclipse.jpt.core.context.orm.OrmPersistentAttribute;
import org.eclipse.jpt.core.internal.context.orm.GenericOrmBasicMapping;
import org.eclipse.jpt.core.resource.orm.XmlBasic;
+import org.eclipse.wst.validation.internal.core.Message;
+import org.eclipse.wst.validation.internal.provisional.core.IMessage;
import org.hibernate.cfg.NamingStrategy;
import org.jboss.tools.hibernate.jpt.core.internal.HibernateJpaProject;
+import org.jboss.tools.hibernate.jpt.core.internal.HibernateJptPlugin;
+import org.jboss.tools.hibernate.jpt.core.internal.context.Messages;
+import
org.jboss.tools.hibernate.jpt.core.internal.context.HibernatePersistenceUnit.LocalMessage;
/**
* @author Dmitry Geraskov
@@ -38,7 +43,13 @@
public String getDefaultColumnName() {
NamingStrategy ns = getJpaProject().getNamingStrategy();
if (ns != null) {
- return ns.propertyToColumnName(getName());
+ try {
+ return ns.propertyToColumnName(getName());
+ } catch (Exception e) {
+ Message m = new LocalMessage(IMessage.HIGH_SEVERITY,
+ Messages.NAMING_STRATEGY_EXCEPTION, new String[0], null);
+ HibernateJptPlugin.logException(m.getText(), e);
+ }
}
return super.getDefaultColumnName();
}
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/orm/HibernateOrmEntity.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/orm/HibernateOrmEntity.java 2009-08-21
01:51:09 UTC (rev 17202)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/orm/HibernateOrmEntity.java 2009-08-21
07:23:56 UTC (rev 17203)
@@ -21,8 +21,13 @@
import org.eclipse.jpt.core.resource.orm.XmlEntity;
import org.eclipse.jpt.core.utility.TextRange;
import org.eclipse.jpt.utility.internal.ClassTools;
+import org.eclipse.wst.validation.internal.core.Message;
+import org.eclipse.wst.validation.internal.provisional.core.IMessage;
import org.hibernate.cfg.NamingStrategy;
import org.jboss.tools.hibernate.jpt.core.internal.HibernateJpaProject;
+import org.jboss.tools.hibernate.jpt.core.internal.HibernateJptPlugin;
+import org.jboss.tools.hibernate.jpt.core.internal.context.Messages;
+import
org.jboss.tools.hibernate.jpt.core.internal.context.HibernatePersistenceUnit.LocalMessage;
/**
* @author Dmitry Geraskov
@@ -52,8 +57,14 @@
}
String className = getClass_();
if (className != null) {
- return ns == null ? ClassTools.shortNameForClassNamed(className)
+ try {
+ return ns == null ? ClassTools.shortNameForClassNamed(className)
: ns.classToTableName(className);
+ } catch (Exception e) {
+ Message m = new LocalMessage(IMessage.HIGH_SEVERITY,
+ Messages.NAMING_STRATEGY_EXCEPTION, new String[0], null);
+ HibernateJptPlugin.logException(m.getText(), e);
+ }
}
return null;
}
@@ -94,12 +105,18 @@
}
Entity parentEntity = HibernateOrmEntity.this.getParentEntity();
NamingStrategy ns = HibernateOrmEntity.this.getJpaProject().getNamingStrategy();
- if (ns == null)
- return parentEntity.getPrimaryKeyColumnName();
-
- String name = ns.joinKeyColumnName(parentEntity.getPrimaryKeyColumnName(),
- parentEntity.getPrimaryTableName());
- return name;
+ if (ns != null){
+ try {
+ String name = ns.joinKeyColumnName(parentEntity.getPrimaryKeyColumnName(),
+ parentEntity.getPrimaryTableName());
+ return name;
+ } catch (Exception e) {
+ Message m = new LocalMessage(IMessage.HIGH_SEVERITY,
+ Messages.NAMING_STRATEGY_EXCEPTION, new String[0], null);
+ HibernateJptPlugin.logException(m.getText(), e);
+ }
+ }
+ return parentEntity.getPrimaryKeyColumnName();
}
public TextRange getValidationTextRange() {
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/orm/HibernateOrmIdMapping.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/orm/HibernateOrmIdMapping.java 2009-08-21
01:51:09 UTC (rev 17202)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/orm/HibernateOrmIdMapping.java 2009-08-21
07:23:56 UTC (rev 17203)
@@ -14,8 +14,13 @@
import org.eclipse.jpt.core.context.orm.OrmPersistentAttribute;
import org.eclipse.jpt.core.internal.context.orm.GenericOrmIdMapping;
import org.eclipse.jpt.core.resource.orm.XmlId;
+import org.eclipse.wst.validation.internal.core.Message;
+import org.eclipse.wst.validation.internal.provisional.core.IMessage;
import org.hibernate.cfg.NamingStrategy;
import org.jboss.tools.hibernate.jpt.core.internal.HibernateJpaProject;
+import org.jboss.tools.hibernate.jpt.core.internal.HibernateJptPlugin;
+import org.jboss.tools.hibernate.jpt.core.internal.context.Messages;
+import
org.jboss.tools.hibernate.jpt.core.internal.context.HibernatePersistenceUnit.LocalMessage;
/**
* @author Dmitry Geraskov
@@ -37,7 +42,13 @@
public String getDefaultColumnName() {
NamingStrategy namingStrategy = getJpaProject().getNamingStrategy();
if (namingStrategy != null && getName() != null){
+ try {
return namingStrategy.propertyToColumnName(getName());
+ } catch (Exception e) {
+ Message m = new LocalMessage(IMessage.HIGH_SEVERITY,
+ Messages.NAMING_STRATEGY_EXCEPTION, new String[0], null);
+ HibernateJptPlugin.logException(m.getText(), e);
+ }
}
return super.getDefaultColumnName();
}