-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add XML-less config to replace persistence.xml and orm.xml #358
Comments
@hantsy could you please give an example of what you're proposing here? |
Provide an annotation like this to define a persistence unit without xml file. @PersistenceUnitDefinition( // @EntityManagerFactoryDefinition
name = "customerDatabase", // mapped to CDI bean name
transactionType="JTA/LOCAL",
excludedUnlistedClasses=false,
dataSourceRef="DefaultDS", // the JNDI name from @DataSourceDefinition
packages= listOf()
classes= listOf()
properties=mapOf() // declaring all *jakarta.* prefixed property as const.
qualifiers=[] // @Qualifier classes
) // repeatable.
@ApplicationScoped
class PersistenceUnits{} And also provides fluent APIs to build EMF, similar to building Hibernate @Dependent
class PersitenceUnitProcducers{
@Inject // or @Resource
DataSource dataSource;
@ApplicationScoped
@Pooled
@CustomerDatabase
EntityManagerFactory emf(EntityManagerFactory.Builder builder){
return builder.name("customerDatabase")
.transactionType(JTA)
.dataSource(dataSource)
.excludedUnlistedClasses(false)
.packages()
.classes()
.properties()
.build();
}
}
|
@hantsy I'm not very keen on the annotation. We do have a thing like that which we use for testing Hibernate, so, I mean, there's precedent for it, but in terms of the spec it's unclear who would have the responsibility for discovering such annotations. If it's the EE container, then I don't see the annotation as very useful. Nor am I very keen on us just unilaterally imposing requirements on standalone CDI implementations. So I don't think that works. On the other hand, a builder API similar to But, I dunno, I guess this would be more of a JPA 4.0 thing? |
Screw it, it's easy enough to do, and there are three different issues requesting it. Please review #465. (Still need to write some words for the spec, but the basic idea is in the Javadoc.) |
Like the
@DataSourceDefinition
, add annotation config for JPA.And additionally provide the capability of using CDI beans(eg. like
EntityManagerFactorBean
role in Spring) to setup JPA.The text was updated successfully, but these errors were encountered: