Author: dgeraskov
Date: 2012-08-21 09:15:00 -0400 (Tue, 21 Aug 2012)
New Revision: 43131
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateJpaProject.java
Log:
https://issues.jboss.org/browse/JBIDE-12451
Fix NPE for projects with orm.xml
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 2012-08-21
12:57:24 UTC (rev 43130)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateJpaProject.java 2012-08-21
13:15:00 UTC (rev 43131)
@@ -25,6 +25,7 @@
import org.eclipse.jpt.jpa.core.JpaProject;
import org.eclipse.jpt.jpa.core.context.persistence.Persistence;
import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit;
+import org.eclipse.jpt.jpa.core.context.persistence.PersistenceXml;
import org.eclipse.jpt.jpa.core.internal.AbstractJpaProject;
import org.eclipse.wst.validation.internal.provisional.core.IMessage;
import org.eclipse.wst.validation.internal.provisional.core.IReporter;
@@ -73,11 +74,14 @@
}
public BasicHibernateProperties getBasicHibernateProperties(){
- Persistence persistence = getRootContextNode().getPersistenceXml().getPersistence();
- if (persistence.getPersistenceUnitsSize() > 0){
- PersistenceUnit persistenceUnit = persistence.getPersistenceUnit(0);
- if (persistenceUnit instanceof HibernatePersistenceUnit) {
- return ((HibernatePersistenceUnit)
persistenceUnit).getHibernatePersistenceUnitProperties();
+ if (getRootContextNode() != null){
+ PersistenceXml persistenceXml = getRootContextNode().getPersistenceXml();
+ Persistence persistence = persistenceXml.getPersistence();
+ if (persistence.getPersistenceUnitsSize() > 0){
+ PersistenceUnit persistenceUnit = persistence.getPersistenceUnit(0);
+ if (persistenceUnit instanceof HibernatePersistenceUnit) {
+ return ((HibernatePersistenceUnit)
persistenceUnit).getHibernatePersistenceUnitProperties();
+ }
}
}
return null;