use of com.querydsl.jpa.codegen.JPADomainExporter in project querydsl by querydsl.
the class AntJPADomainExporter method execute.
/**
* Exports the named persistence unit's metamodel to Querydsl query types. Expects to be
* called by Ant via name convention using a method with signature public void execute().
*/
public void execute() {
// We can assume we have the named persistence unit and its mapping file in our classpath,
// but we may have to allow some properties in that persistence unit to be overridden before
// we can successfully get that persistence unit's metamodel.
Map<String, String> properties = (configuration != null) ? configuration.getProperties() : null;
EntityManagerFactory emf = Persistence.createEntityManagerFactory(persistenceUnitName, properties);
// Now we can get the persistence unit's metamodel and export it to Querydsl query types.
Metamodel configuration = emf.getMetamodel();
JPADomainExporter exporter = new JPADomainExporter(namePrefix, nameSuffix, new File(targetFolder), configuration);
try {
exporter.execute();
generatedFiles = exporter.getGeneratedFiles();
} catch (IOException e) {
throw new RuntimeException("Error in JPADomainExporter", e);
}
}
Aggregations