Refine search
@NamedNativeQuery(name = "Subscription.findAllSubscriptionSummaries", // query = "select product_name as productName, count(user_id) as subscriptions from subscription group by product_name order by productName", // resultSetMapping = "subscriptionSummary"), @NamedNativeQuery(name = "Subscription.findAllSubscriptionProjections", // query = "select product_name as product, count(user_id) as usageCount from subscription group by product_name order by product") }) })) @Entity @Data @NoArgsConstructor(force = true, access = AccessLevel.PRIVATE)
name.setValue(query.name()); namedQuery.addMemberValue("name", name); queryString.setValue(query.query()); namedQuery.addMemberValue("query", queryString); resultClass.setValue(query.resultClass().getName()); namedQuery.addMemberValue("resultClass", resultClass); resultSetMapping.setValue(query.resultSetMapping()); namedQuery.addMemberValue("resultSetMapping", resultSetMapping); for (QueryHint hint : query.hints()) { prepareQueryHints(constantPool, queryHints, hint);
private void addNamedNativeQueryIfNeeded(NamedNativeQuery annotation, List<NamedNativeQuery> queries) { if ( annotation != null ) { String queryName = annotation.name(); boolean present = false; for ( NamedNativeQuery current : queries ) { if ( current.name().equals( queryName ) ) { present = true; break; } } if ( !present ) { queries.add( annotation ); } } }
@NamedNativeQueries( @NamedNativeQuery( name = "com.thesett.util.dao.ViewsDAO.findAllWithPrefix", query = "SELECT table_name" +
private void addNamedNativeQueryIfNeeded(NamedNativeQuery annotation, List<NamedNativeQuery> queries) { if ( annotation != null ) { String queryName = annotation.name(); boolean present = false; for (NamedNativeQuery current : queries) { if ( current.name().equals( queryName ) ) { present = true; break; } } if ( !present ) queries.add( annotation ); } }
@Entity @Table(name = "destination_entity") @NamedNativeQueries({ @NamedNativeQuery(name = "DestinationEntity.insertSelect", query = "insert into destination_entity(id, from_id, fullNameFrom) " + " select fe.id, fe.id, fe.name||fe.lastName from from_entity fe where fe.id in (:ids)"), @NamedNativeQuery(name = "DestinationEntity.insert", query = "insert into destination_entity(id, from_id, fullNameFrom) " + "values (:generatedId, :fromId, :fullName)"), @NamedNativeQuery(name = "DestinationEntity.update", query = "update destination_entity set from_id=:idFrom, fullNameFrom=:fullName" + " where id in (:ids)"), @NamedNativeQuery(name = "DestinationEntity.delete", query = "delete from destination_entity where id in (:ids)"), @NamedNativeQuery(name = "DestinationEntity.selectIds", query = "select id, from_id, fullNameFrom from destination_entity where id in (:ids) order by id") }) public class DestinationEntity {
if ( queryAnn == null ) return; if ( BinderHelper.isEmptyAnnotationValue( queryAnn.name() ) ) { throw new AnnotationException( "A named query must have a name when used in class or package level" ); String resultSetMapping = queryAnn.resultSetMapping(); QueryHintDefinition hints = new QueryHintDefinition( queryAnn.hints() ); String queryName = queryAnn.query(); NamedSQLQueryDefinitionBuilder builder = new NamedSQLQueryDefinitionBuilder( queryAnn.name() ) .setQuery( queryName ) .setQuerySpaces( null ) .createNamedQueryDefinition(); else if ( !void.class.equals( queryAnn.resultClass() ) ) { new NativeSQLQueryRootReturn( "alias1", queryAnn.resultClass().getName(), new HashMap(), LockMode.READ ); builder.setQueryReturns( new NativeSQLQueryReturn[] {entityQueryReturn} ); LOG.debugf( "Binding named native query: %s => %s", queryAnn.name(), queryAnn.query() );
public <I extends BaseNature, A extends Annotation> boolean processAnnotation( final I info, final A annotation, final AnnotatedElement target) throws AnnotationTargetException { if ((info instanceof JPAClassNature) && (annotation instanceof NamedNativeQuery) && (target instanceof Class<?>) && (target.isAnnotationPresent(NamedNativeQuery.class))) { LOG.debug("Processing class annotation " + annotation.toString()); final JPAClassNature jpaClassNature = (JPAClassNature) info; final NamedNativeQuery namedNativeQuery = (NamedNativeQuery) annotation; final Map<String, String> namedNativeQueryMap = new HashMap<String,String>(); namedNativeQueryMap.put(namedNativeQuery.name(), namedNativeQuery.query()); jpaClassNature.setNamedNativeQuery(namedNativeQueryMap); return true; } return false; }
private boolean hasNamedNativeQuery(String query, NamedNativeQuery... queries) { for (NamedNativeQuery q : queries) { if (query.equals(q.name())) return true; } return false; }
/** * @author Emmanuel Bernard */ @Entity @Table(name = "matchtable", schema = "matchschema") @SecondaryTable(name = "extendedMatch") @Inheritance(strategy = InheritanceType.TABLE_PER_CLASS) @NamedQueries({ @NamedQuery(name = "matchbyid", query = "select m from Match m where m.id = :id"), @NamedQuery(name = "getAllMatches2", query = "select m from Match m") }) @NamedNativeQueries({ @NamedNativeQuery(name = "matchbyid", query = "select m from Match m where m.id = :id", resultSetMapping = "matchrs"), @NamedNativeQuery(name = "getAllMatches2", query = "select m from Match m", resultSetMapping = "matchrs") }) public class Match extends Competition { public String competitor1Point; @Version public Integer version; public SocialSecurityNumber playerASSN; }
public static void bindNativeQuery(NamedNativeQuery queryAnn, ExtendedMappings mappings, boolean isDefault) { if ( queryAnn == null ) return; if ( BinderHelper.isDefault( queryAnn.name() ) ) { throw new AnnotationException( "A named query must have a name when used in class or package level" ); String resultSetMapping = queryAnn.resultSetMapping(); QueryHint[] hints = queryAnn.hints(); String queryName = queryAnn.query(); if ( !BinderHelper.isDefault( resultSetMapping ) ) { ); else if ( !void.class.equals( queryAnn.resultClass() ) ) { new NativeSQLQueryRootReturn( "alias1", queryAnn.resultClass().getName(), new HashMap(), LockMode.READ ); query = new NamedSQLQueryDefinition( queryName, mappings.addDefaultSQLQuery( queryAnn.name(), query ); mappings.addSQLQuery( queryAnn.name(), query ); log.info( "Binding named native query: {} => {}", queryAnn.name(), queryAnn.query() );
public <I extends BaseNature, A extends Annotation> boolean processAnnotation( final I info, final A annotation, final AnnotatedElement target) throws AnnotationTargetException { if ((info instanceof JPAClassNature) && (annotation instanceof NamedNativeQueries) && (target instanceof Class<?>) && (target.isAnnotationPresent(NamedNativeQueries.class))) { LOG.debug("Processing class annotation " + annotation.toString()); final JPAClassNature jpaClassNature = (JPAClassNature) info; final NamedNativeQueries namedNativeQueries = (NamedNativeQueries) annotation; final NamedNativeQuery[] namedNativeQueryValues = namedNativeQueries .value(); final Map<String, String> namedNativeQueryMap = new HashMap<String, String>(); if (namedNativeQueryValues != null && namedNativeQueryValues.length > 0) { for (NamedNativeQuery query : namedNativeQueryValues) { namedNativeQueryMap.put(query.name(), query.query()); } } jpaClassNature.setNamedNativeQuery(namedNativeQueryMap); return true; } return false; }
private boolean hasNamedNativeQuery(String query, NamedNativeQuery... queries) { for (NamedNativeQuery q : queries) { if (query.equals(q.name())) return true; } return false; }
@Entity @Table(name = "domainadmin") @IdClass(DomainAdminId.class) @NamedNativeQuery(name = "DomainAdmin.testQuery", query = "select * from domainadmin da where da.domain_name = 'org'", resultClass = org.hibernate.test.annotations.idclass.DomainAdmin.class)
private NamedQueryInfo(NamedNativeQuery theQuery) { mName = theQuery.name(); mQuery = theQuery.query(); mResultMapping = theQuery.resultSetMapping(); mResultClass = theQuery.resultClass(); mHints = Arrays.asList(theQuery.hints()); }
private boolean hasNamedNativeQuery(String query, NamedNativeQuery... queries) { for (NamedNativeQuery q : queries) { if (query.equals(q.name())) return true; } return false; }
@Entity(name = "Game") @NamedQueries(@NamedQuery(name = "NamedQuery", query = "select g from Game g where title = ?1")) @NamedNativeQueries(@NamedNativeQuery(name = "NamedNativeQuery", query = "select * from Game g where title = ?")) public static class Game { private Long id;
/** * @param locator * the locator * @param annotation * the annotation * * @since 2.0.0 */ public NamedNativeQueryMetadataImpl(AbstractLocator locator, NamedNativeQuery annotation) { super(); this.locator = locator; this.name = annotation.name(); this.query = annotation.query(); this.resultClass = annotation.resultClass().getName(); this.resultSetMapping = annotation.resultSetMapping(); for (final QueryHint hint : annotation.hints()) { this.hints.put(hint.name(), hint.value()); } }