Support default session getters
In which case, we don't store the session in the DAO, we always call the getter
This commit is contained in:
parent
1f3aed022c
commit
ed29057315
|
@ -138,6 +138,11 @@ public class AnnotationMetaEntity extends AnnotationMeta {
|
|||
*/
|
||||
private String sessionType = Constants.ENTITY_MANAGER;
|
||||
|
||||
/**
|
||||
* The field or method call to obtain the session
|
||||
*/
|
||||
private String sessionGetter = "entityManager";
|
||||
|
||||
private final Map<String,String> memberTypes = new HashMap<>();
|
||||
|
||||
public AnnotationMetaEntity(
|
||||
|
@ -484,6 +489,8 @@ public class AnnotationMetaEntity extends AnnotationMeta {
|
|||
final String sessionVariableName = getSessionVariableName( sessionType );
|
||||
final String name = method == null ? sessionVariableName : method.getSimpleName().toString();
|
||||
final String typeName = element.getSimpleName().toString() + '_';
|
||||
|
||||
if( method == null || !method.isDefault() ) {
|
||||
putMember( name,
|
||||
new RepositoryConstructor(
|
||||
this,
|
||||
|
@ -499,6 +506,11 @@ public class AnnotationMetaEntity extends AnnotationMeta {
|
|||
quarkusInjection
|
||||
)
|
||||
);
|
||||
}
|
||||
else {
|
||||
// use this getter to get the method, do not generate an injection point for its type
|
||||
sessionGetter = method.getSimpleName() + "()";
|
||||
}
|
||||
return sessionType;
|
||||
}
|
||||
|
||||
|
@ -1088,14 +1100,14 @@ public class AnnotationMetaEntity extends AnnotationMeta {
|
|||
return getSessionVariableName(sessionType);
|
||||
}
|
||||
|
||||
private static String getSessionVariableName(String sessionType) {
|
||||
private String getSessionVariableName(String sessionType) {
|
||||
switch (sessionType) {
|
||||
case HIB_SESSION:
|
||||
case HIB_STATELESS_SESSION:
|
||||
case MUTINY_SESSION:
|
||||
return "session";
|
||||
default:
|
||||
return "entityManager";
|
||||
return sessionGetter;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue