This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package demo; | |
| import java.util.concurrent.TimeUnit; | |
| import org.springframework.aop.TargetSource; | |
| import org.springframework.aop.framework.ProxyFactory; | |
| import org.springframework.aop.support.DelegatingIntroductionInterceptor; | |
| import org.springframework.beans.factory.BeanFactory; | |
| import org.springframework.boot.SpringApplication; | |
| import org.springframework.boot.autoconfigure.SpringBootApplication; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package demo; | |
| import java.util.List; | |
| import javax.persistence.Entity; | |
| import javax.persistence.GeneratedValue; | |
| import javax.persistence.Id; | |
| import org.springframework.boot.CommandLineRunner; | |
| import org.springframework.boot.SpringApplication; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| XuxuService service = new XuxuServiceImpl(); | |
| RetryAndNotifyOnErrorAspect myaspect = new RetryAndNotifyOnErrorAspect(); | |
| AspectJProxyFactory factory = new AspectJProxyFactory(service); | |
| factory.addAspect(myaspect); | |
| // factory.setProxyTargetClass(true); // if you're applying to a concrete class | |
| XuxuService proxy = factory.getProxy(); | |
| // just run it | |
| proxy.execute(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| USE AdventureWorks2008R2 | |
| GO | |
| SET ANSI_NULLS ON | |
| GO | |
| SET QUOTED_IDENTIFIER ON | |
| GO | |
| IF OBJECT_ID('Purchasing.usp_AT_uPurchaseOrderDetail', 'P') IS NOT NULL | |
| DROP PROCEDURE Purchasing.usp_AT_uPurchaseOrderDetail; | |
| GO | |
| CREATE PROCEDURE Purchasing.usp_AT_uPurchaseOrderDetail |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import com.github.tennaito.rsql.misc.ArgumentFormatException; | |
| import com.github.tennaito.rsql.misc.DefaultArgumentParser; | |
| import java.sql.Timestamp; | |
| import java.time.ZonedDateTime; | |
| import java.time.format.DateTimeFormatter; | |
| // default DefaultArgumentParser can't parse Timestamps :( | |
| public class CustomizedArgumentParser extends DefaultArgumentParser { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // @see http://antoniogoncalves.org/2012/05/24/how-to-get-the-jpqlsql-string-from-a-criteriaquery-in-jpa/ | |
| TypedQuery<X> q = entityManager.createQuery(cq); | |
| try { | |
| Class<?> hibernateQueryClass = Class.forName("org.hibernate.Query"); | |
| Object hibernateQuery = q.unwrap(hibernateQueryClass); | |
| java.lang.reflect.Method getQueryStringMethod = hibernateQueryClass.getMethod("getQueryString"); | |
| Object hql = getQueryStringMethod.invoke(hibernateQuery); | |
| LOGGER.warn("hql = {}", hql); | |
| } catch (ClassNotFoundException | NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | java.lang.reflect.InvocationTargetException ex) { | |
| ex.printStackTrace(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class RepositoryImpl<T, ID extends Serializable> | |
| extends SimpleJpaRepository<T, ID extends Serializable> { | |
| ProjectionFactory projectionFactory; | |
| public <P> List<P> findProjected(Specification<?> spec, Sort sort, Class<P> projectionClass) { | |
| CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder(); | |
| CriteriaQuery<Tuple> tupleQuery = criteriaBuilder.createTupleQuery(); | |
| Root<?> root = tupleQuery.from(getDomainClass()); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package org.kraven.repository; | |
| import org.kraven.domain.DeviceData; | |
| import org.springframework.data.jpa.repository.JpaSpecificationExecutor; | |
| /** | |
| * Spring Data JPA repository for the DeviceData entity. | |
| */ | |
| @SuppressWarnings("unused") | |
| public interface DeviceDataRepository extends JpaRepository<DeviceData,Long>, JpaSpecificationExecutor<DeviceData> { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.lang.annotation.Retention; | |
| import java.lang.annotation.RetentionPolicy; | |
| import java.lang.reflect.InvocationHandler; | |
| import java.lang.reflect.Method; | |
| import java.lang.reflect.Proxy; | |
| import java.util.HashMap; | |
| import java.util.Map; | |
| import org.junit.Assert; | |
| import org.junit.Test; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import org.apache.commons.collections4.CollectionUtils; | |
| import org.apache.commons.collections4.IteratorUtils; | |
| import org.apache.commons.lang3.StringUtils; | |
| import org.hibernate.query.criteria.internal.path.PluralAttributePath; | |
| import org.springframework.data.domain.Page; | |
| import org.springframework.data.domain.PageRequest; | |
| import org.springframework.data.repository.support.PageableExecutionUtils; | |
| import javax.persistence.EntityManager; | |
| import javax.persistence.TypedQuery; |
NewerOlder