Search in sources :

Example 1 with PersistenceXml

use of org.eclipse.jpt.jpa.core.context.persistence.PersistenceXml in project jbosstools-hibernate by jbosstools.

the class HibernateJpaProject method getBasicHibernateProperties.

public BasicHibernateProperties getBasicHibernateProperties() {
    if (getContextRoot() != null) {
        PersistenceXml persistenceXml = getContextRoot().getPersistenceXml();
        Persistence persistence = persistenceXml.getRoot();
        if (persistence.getPersistenceUnitsSize() > 0) {
            PersistenceUnit persistenceUnit = persistence.getPersistenceUnit(0);
            if (persistenceUnit instanceof HibernatePersistenceUnit) {
                return ((HibernatePersistenceUnit) persistenceUnit).getHibernatePersistenceUnitProperties();
            }
        }
    }
    return null;
}
Also used : Persistence(org.eclipse.jpt.jpa.core.context.persistence.Persistence) PersistenceXml(org.eclipse.jpt.jpa.core.context.persistence.PersistenceXml) HibernatePersistenceUnit(org.jboss.tools.hibernate.jpt.core.internal.context.HibernatePersistenceUnit) PersistenceUnit(org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit) HibernatePersistenceUnit(org.jboss.tools.hibernate.jpt.core.internal.context.HibernatePersistenceUnit)

Example 2 with PersistenceXml

use of org.eclipse.jpt.jpa.core.context.persistence.PersistenceXml in project jbosstools-hibernate by jbosstools.

the class AddGeneratedClassesJob method mappingFileContains.

boolean mappingFileContains(JpaProject jpaProject, String fullyQualifiedTypeName) {
    PersistenceXml persistenceXml = jpaProject.getContextRoot().getPersistenceXml();
    if (persistenceXml == null) {
        return false;
    }
    Persistence persistence = persistenceXml.getRoot();
    if (persistence == null) {
        return false;
    }
    if (persistence.getPersistenceUnitsSize() == 0) {
        return false;
    }
    PersistenceUnit persistenceUnit = persistence.getPersistenceUnit(0);
    for (MappingFileRef mappingFileRef : persistenceUnit.getMappingFileRefs()) {
        if (mappingFileRef.getPersistentType(fullyQualifiedTypeName) != null) {
            return true;
        }
    }
    return false;
}
Also used : Persistence(org.eclipse.jpt.jpa.core.context.persistence.Persistence) XmlPersistence(org.eclipse.jpt.jpa.core.resource.persistence.XmlPersistence) PersistenceXml(org.eclipse.jpt.jpa.core.context.persistence.PersistenceXml) PersistenceUnit(org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit) XmlPersistenceUnit(org.eclipse.jpt.jpa.core.resource.persistence.XmlPersistenceUnit) MappingFileRef(org.eclipse.jpt.jpa.core.context.persistence.MappingFileRef)

Aggregations

Persistence (org.eclipse.jpt.jpa.core.context.persistence.Persistence)2 PersistenceUnit (org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit)2 PersistenceXml (org.eclipse.jpt.jpa.core.context.persistence.PersistenceXml)2 MappingFileRef (org.eclipse.jpt.jpa.core.context.persistence.MappingFileRef)1 XmlPersistence (org.eclipse.jpt.jpa.core.resource.persistence.XmlPersistence)1 XmlPersistenceUnit (org.eclipse.jpt.jpa.core.resource.persistence.XmlPersistenceUnit)1 HibernatePersistenceUnit (org.jboss.tools.hibernate.jpt.core.internal.context.HibernatePersistenceUnit)1