Author: dgeraskov
Date: 2011-10-31 09:21:54 -0400 (Mon, 31 Oct 2011)
New Revision: 36089
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/orm/HibernateOrmBasicMapping.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/orm/HibernateOrmEntityImpl.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/orm/HibernateOrmIdMappingImpl.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/orm/HibernateOrmTableImpl.java
Log:
https://issues.jboss.org/browse/JBIDE-10079
Added null checks
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 2011-10-31
13:21:07 UTC (rev 36088)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/Messages.properties 2011-10-31
13:21:54 UTC (rev 36089)
@@ -3,7 +3,7 @@
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\".
-NAMING_STRATEGY_EXCEPTION = Exception occurred when calling NamingStrategy:
+NAMING_STRATEGY_EXCEPTION = Exception occurred when calling NamingStrategy
UNRESOLVED_FOREIGN_KEY_NAME = Foreign key \"{0}\" not found in the table
\"{1}\".
CC_NOT_EXISTS= Console configuration \"{0}\" does not exist.
TYPE_CANT_BE_EMPTY=Type could not be empty.
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 2011-10-31
13:21:07 UTC (rev 36088)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/orm/HibernateOrmBasicMapping.java 2011-10-31
13:21:54 UTC (rev 36089)
@@ -40,15 +40,17 @@
@Override
public String getDefaultColumnName() {
- NamingStrategy ns = getJpaProject().getNamingStrategy();
- if (getJpaProject().isNamingStrategyEnabled() && ns != null) {
- try {
- return ns.propertyToColumnName(getName());
- } catch (Exception e) {
- IMessage m = HibernateJpaValidationMessage.buildMessage(
- IMessage.HIGH_SEVERITY,
- Messages.NAMING_STRATEGY_EXCEPTION, null);
- HibernateJptPlugin.logException(m.getText(), e);
+ if (getName() != null){
+ NamingStrategy ns = getJpaProject().getNamingStrategy();
+ if (getJpaProject().isNamingStrategyEnabled() && ns != null) {
+ try {
+ return ns.propertyToColumnName(getName());
+ } catch (Exception e) {
+ IMessage m = HibernateJpaValidationMessage.buildMessage(
+ IMessage.HIGH_SEVERITY,
+ Messages.NAMING_STRATEGY_EXCEPTION, 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/HibernateOrmEntityImpl.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/orm/HibernateOrmEntityImpl.java 2011-10-31
13:21:07 UTC (rev 36088)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/orm/HibernateOrmEntityImpl.java 2011-10-31
13:21:54 UTC (rev 36089)
@@ -187,18 +187,20 @@
}
Entity parentEntity = HibernateOrmEntityImpl.this.getParentEntity();
String colName = (parentEntity == null)
- ? getPrimaryKeyColumnName() : parentEntity.getPrimaryKeyColumnName();
- NamingStrategy ns = HibernateOrmEntityImpl.this.getJpaProject().getNamingStrategy();
- if (getJpaProject().isNamingStrategyEnabled() && ns != null){
- try {
- String name = ns.joinKeyColumnName(colName, (parentEntity == null)
- ? getTable().getName() : parentEntity.getPrimaryTableName());
- return name;
- } catch (Exception e) {
- IMessage m = HibernateJpaValidationMessage.buildMessage(
- IMessage.HIGH_SEVERITY,
- Messages.NAMING_STRATEGY_EXCEPTION,null);
- HibernateJptPlugin.logException(m.getText(), e);
+ ? getPrimaryKeyColumnName() : parentEntity.getPrimaryKeyColumnName();
+ if (colName != null){
+ NamingStrategy ns = HibernateOrmEntityImpl.this.getJpaProject().getNamingStrategy();
+ if (getJpaProject().isNamingStrategyEnabled() && ns != null){
+ try {
+ String name = ns.joinKeyColumnName(colName, (parentEntity == null)
+ ? getTable().getName() : parentEntity.getPrimaryTableName());
+ return name;
+ } catch (Exception e) {
+ IMessage m = HibernateJpaValidationMessage.buildMessage(
+ IMessage.HIGH_SEVERITY,
+ Messages.NAMING_STRATEGY_EXCEPTION,null);
+ HibernateJptPlugin.logException(m.getText(), e);
+ }
}
}
return colName;
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/orm/HibernateOrmIdMappingImpl.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/orm/HibernateOrmIdMappingImpl.java 2011-10-31
13:21:07 UTC (rev 36088)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/orm/HibernateOrmIdMappingImpl.java 2011-10-31
13:21:54 UTC (rev 36089)
@@ -44,15 +44,17 @@
@Override
public String getDefaultColumnName() {
- NamingStrategy namingStrategy = getJpaProject().getNamingStrategy();
- if (getJpaProject().isNamingStrategyEnabled() && namingStrategy != null
&& getName() != null){
- try {
- return namingStrategy.propertyToColumnName(getName());
- } catch (Exception e) {
- IMessage m = HibernateJpaValidationMessage.buildMessage(
- IMessage.HIGH_SEVERITY,
- Messages.NAMING_STRATEGY_EXCEPTION, null);
- HibernateJptPlugin.logException(m.getText(), e);
+ if (getName() != null){
+ NamingStrategy namingStrategy = getJpaProject().getNamingStrategy();
+ if (getJpaProject().isNamingStrategyEnabled() && namingStrategy != null){
+ try {
+ return namingStrategy.propertyToColumnName(getName());
+ } catch (Exception e) {
+ IMessage m = HibernateJpaValidationMessage.buildMessage(
+ IMessage.HIGH_SEVERITY,
+ Messages.NAMING_STRATEGY_EXCEPTION, 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/HibernateOrmTableImpl.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/orm/HibernateOrmTableImpl.java 2011-10-31
13:21:07 UTC (rev 36088)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/orm/HibernateOrmTableImpl.java 2011-10-31
13:21:54 UTC (rev 36089)
@@ -72,15 +72,17 @@
}
protected String buildDefaultDBTableName(){
- NamingStrategy ns = getJpaProject().getNamingStrategy();
- if (getJpaProject().isNamingStrategyEnabled() && ns != null) {
- try {
- return ns.classToTableName(getDefaultName());
- } catch (Exception e) {
- IMessage m = HibernateJpaValidationMessage.buildMessage(
- IMessage.HIGH_SEVERITY,
- Messages.NAMING_STRATEGY_EXCEPTION, null);
- HibernateJptPlugin.logException(m.getText(), e);
+ if (getDefaultName() != null){
+ NamingStrategy ns = getJpaProject().getNamingStrategy();
+ if (getJpaProject().isNamingStrategyEnabled() && ns != null) {
+ try {
+ return ns.classToTableName(getDefaultName());
+ } catch (Exception e) {
+ IMessage m = HibernateJpaValidationMessage.buildMessage(
+ IMessage.HIGH_SEVERITY,
+ Messages.NAMING_STRATEGY_EXCEPTION, this);
+ HibernateJptPlugin.logException(m.getText(), e);
+ }
}
}
return this.getDefaultName();