HHH-8266 Binding of named-stored-procedure XML element tries to create duplicate
This commit is contained in:
parent
7678fae6a5
commit
5ea40ce3f5
|
@ -272,7 +272,7 @@ public final class AnnotationBinder {
|
||||||
(List<NamedStoredProcedureQuery>) defaults.get( NamedStoredProcedureQuery.class );
|
(List<NamedStoredProcedureQuery>) defaults.get( NamedStoredProcedureQuery.class );
|
||||||
if ( annotations != null ) {
|
if ( annotations != null ) {
|
||||||
for ( NamedStoredProcedureQuery annotation : annotations ) {
|
for ( NamedStoredProcedureQuery annotation : annotations ) {
|
||||||
bindNamedStoredProcedureQuery( mappings, annotation );
|
bindNamedStoredProcedureQuery( mappings, annotation, true );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -281,7 +281,7 @@ public final class AnnotationBinder {
|
||||||
(List<NamedStoredProcedureQueries>) defaults.get( NamedStoredProcedureQueries.class );
|
(List<NamedStoredProcedureQueries>) defaults.get( NamedStoredProcedureQueries.class );
|
||||||
if ( annotations != null ) {
|
if ( annotations != null ) {
|
||||||
for ( NamedStoredProcedureQueries annotation : annotations ) {
|
for ( NamedStoredProcedureQueries annotation : annotations ) {
|
||||||
bindNamedStoredProcedureQueries( mappings, annotation );
|
bindNamedStoredProcedureQueries( mappings, annotation, true );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -392,26 +392,27 @@ public final class AnnotationBinder {
|
||||||
}
|
}
|
||||||
|
|
||||||
// NamedStoredProcedureQuery handling ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
// NamedStoredProcedureQuery handling ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
bindNamedStoredProcedureQuery( mappings, annotatedElement.getAnnotation( NamedStoredProcedureQuery.class ) );
|
bindNamedStoredProcedureQuery( mappings, annotatedElement.getAnnotation( NamedStoredProcedureQuery.class ), false );
|
||||||
|
|
||||||
// NamedStoredProcedureQueries handling ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
// NamedStoredProcedureQueries handling ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
bindNamedStoredProcedureQueries(
|
bindNamedStoredProcedureQueries(
|
||||||
mappings,
|
mappings,
|
||||||
annotatedElement.getAnnotation( NamedStoredProcedureQueries.class )
|
annotatedElement.getAnnotation( NamedStoredProcedureQueries.class ),
|
||||||
|
false
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void bindNamedStoredProcedureQueries(Mappings mappings, NamedStoredProcedureQueries annotation) {
|
private static void bindNamedStoredProcedureQueries(Mappings mappings, NamedStoredProcedureQueries annotation, boolean isDefault) {
|
||||||
if ( annotation != null ) {
|
if ( annotation != null ) {
|
||||||
for ( NamedStoredProcedureQuery queryAnnotation : annotation.value() ) {
|
for ( NamedStoredProcedureQuery queryAnnotation : annotation.value() ) {
|
||||||
bindNamedStoredProcedureQuery( mappings, queryAnnotation );
|
bindNamedStoredProcedureQuery( mappings, queryAnnotation, isDefault );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void bindNamedStoredProcedureQuery(Mappings mappings, NamedStoredProcedureQuery annotation) {
|
private static void bindNamedStoredProcedureQuery(Mappings mappings, NamedStoredProcedureQuery annotation, boolean isDefault) {
|
||||||
if ( annotation != null ) {
|
if ( annotation != null ) {
|
||||||
QueryBinder.bindNamedStoredProcedureQuery( annotation, mappings );
|
QueryBinder.bindNamedStoredProcedureQuery( annotation, mappings, isDefault );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -263,6 +263,8 @@ public class Configuration implements Serializable {
|
||||||
private Set<String> defaultNamedQueryNames;
|
private Set<String> defaultNamedQueryNames;
|
||||||
private Set<String> defaultNamedNativeQueryNames;
|
private Set<String> defaultNamedNativeQueryNames;
|
||||||
private Set<String> defaultSqlResultSetMappingNames;
|
private Set<String> defaultSqlResultSetMappingNames;
|
||||||
|
private Set<String> defaultNamedProcedure;
|
||||||
|
|
||||||
private Set<String> defaultNamedGenerators;
|
private Set<String> defaultNamedGenerators;
|
||||||
private Map<String, Properties> generatorTables;
|
private Map<String, Properties> generatorTables;
|
||||||
private Map<Table, List<UniqueConstraintHolder>> uniqueConstraintHoldersByTable;
|
private Map<Table, List<UniqueConstraintHolder>> uniqueConstraintHoldersByTable;
|
||||||
|
@ -339,6 +341,7 @@ public class Configuration implements Serializable {
|
||||||
defaultNamedQueryNames = new HashSet<String>();
|
defaultNamedQueryNames = new HashSet<String>();
|
||||||
defaultNamedNativeQueryNames = new HashSet<String>();
|
defaultNamedNativeQueryNames = new HashSet<String>();
|
||||||
defaultSqlResultSetMappingNames = new HashSet<String>();
|
defaultSqlResultSetMappingNames = new HashSet<String>();
|
||||||
|
defaultNamedProcedure = new HashSet<String>( );
|
||||||
defaultNamedGenerators = new HashSet<String>();
|
defaultNamedGenerators = new HashSet<String>();
|
||||||
uniqueConstraintHoldersByTable = new HashMap<Table, List<UniqueConstraintHolder>>();
|
uniqueConstraintHoldersByTable = new HashMap<Table, List<UniqueConstraintHolder>>();
|
||||||
jpaIndexHoldersByTable = new HashMap<Table,List<JPAIndexHolder>>( );
|
jpaIndexHoldersByTable = new HashMap<Table,List<JPAIndexHolder>>( );
|
||||||
|
@ -2890,16 +2893,25 @@ public class Configuration implements Serializable {
|
||||||
public void addNamedProcedureCallDefinition(NamedProcedureCallDefinition definition)
|
public void addNamedProcedureCallDefinition(NamedProcedureCallDefinition definition)
|
||||||
throws DuplicateMappingException {
|
throws DuplicateMappingException {
|
||||||
final String name = definition.getRegisteredName();
|
final String name = definition.getRegisteredName();
|
||||||
|
if ( !defaultNamedProcedure.contains( name ) ) {
|
||||||
final NamedProcedureCallDefinition previous = namedProcedureCallMap.put( name, definition );
|
final NamedProcedureCallDefinition previous = namedProcedureCallMap.put( name, definition );
|
||||||
if ( previous != null ) {
|
if ( previous != null ) {
|
||||||
throw new DuplicateMappingException( "named stored procedure query", name );
|
throw new DuplicateMappingException( "named stored procedure query", name );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void addDefaultNamedProcedureCallDefinition(NamedProcedureCallDefinition definition)
|
||||||
|
throws DuplicateMappingException {
|
||||||
|
addNamedProcedureCallDefinition( definition );
|
||||||
|
defaultNamedProcedure.add( definition.getRegisteredName() );
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addNamedEntityGraphDefintion(NamedEntityGraphDefinition definition)
|
public void addNamedEntityGraphDefintion(NamedEntityGraphDefinition definition)
|
||||||
throws DuplicateMappingException {
|
throws DuplicateMappingException {
|
||||||
final String name = definition.getRegisteredName();
|
final String name = definition.getRegisteredName();
|
||||||
|
|
||||||
final NamedEntityGraphDefinition previous = namedEntityGraphMap.put( name, definition );
|
final NamedEntityGraphDefinition previous = namedEntityGraphMap.put( name, definition );
|
||||||
if ( previous != null ) {
|
if ( previous != null ) {
|
||||||
throw new DuplicateMappingException( "NamedEntityGraph", name );
|
throw new DuplicateMappingException( "NamedEntityGraph", name );
|
||||||
|
|
|
@ -349,6 +349,17 @@ public interface Mappings {
|
||||||
*/
|
*/
|
||||||
public void addNamedProcedureCallDefinition(NamedProcedureCallDefinition definition) throws DuplicateMappingException;
|
public void addNamedProcedureCallDefinition(NamedProcedureCallDefinition definition) throws DuplicateMappingException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds metadata for a named stored procedure call to this repository.
|
||||||
|
*
|
||||||
|
* @param definition The procedure call information
|
||||||
|
*
|
||||||
|
* @throws DuplicateMappingException If a query already exists with that name.
|
||||||
|
*/
|
||||||
|
public void addDefaultNamedProcedureCallDefinition(NamedProcedureCallDefinition definition) throws DuplicateMappingException;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds metadata for a named entity graph to this repository
|
* Adds metadata for a named entity graph to this repository
|
||||||
*
|
*
|
||||||
|
|
|
@ -318,7 +318,7 @@ public abstract class QueryBinder {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void bindNamedStoredProcedureQuery(NamedStoredProcedureQuery annotation, Mappings mappings) {
|
public static void bindNamedStoredProcedureQuery(NamedStoredProcedureQuery annotation, Mappings mappings, boolean isDefault) {
|
||||||
if ( annotation == null ) {
|
if ( annotation == null ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -328,7 +328,12 @@ public abstract class QueryBinder {
|
||||||
}
|
}
|
||||||
|
|
||||||
final NamedProcedureCallDefinition def = new NamedProcedureCallDefinition( annotation );
|
final NamedProcedureCallDefinition def = new NamedProcedureCallDefinition( annotation );
|
||||||
|
|
||||||
|
if(isDefault){
|
||||||
|
mappings.addDefaultNamedProcedureCallDefinition( def );
|
||||||
|
} else{
|
||||||
mappings.addNamedProcedureCallDefinition( def );
|
mappings.addNamedProcedureCallDefinition( def );
|
||||||
|
}
|
||||||
LOG.debugf( "Bound named stored procedure query : %s => %s", def.getRegisteredName(), def.getProcedureName() );
|
LOG.debugf( "Bound named stored procedure query : %s => %s", def.getRegisteredName(), def.getProcedureName() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue