spring-data

Is there generic Specification for JPASpecificationExecutor to use in Web

淺唱寂寞╮ 提交于 2020-01-23 18:24:21
问题 Spring Data has a native web support for Pageable send over the web, as parameters in HTML Query, through PageableHandlerMethodArgumentResolver. I have not found JPA Specification executor for that, which from my point of view would be very useful. Is there one? 回答1: The reason that there's no generic one available for you is that the predicates you build in it is completely depending on your domain model. A good example for how to use Specification s with Spring MVC can be found in the

Is there generic Specification for JPASpecificationExecutor to use in Web

僤鯓⒐⒋嵵緔 提交于 2020-01-23 18:24:06
问题 Spring Data has a native web support for Pageable send over the web, as parameters in HTML Query, through PageableHandlerMethodArgumentResolver. I have not found JPA Specification executor for that, which from my point of view would be very useful. Is there one? 回答1: The reason that there's no generic one available for you is that the predicates you build in it is completely depending on your domain model. A good example for how to use Specification s with Spring MVC can be found in the

JPA - OneToOne Foreign key as primary key

℡╲_俬逩灬. 提交于 2020-01-23 03:45:26
问题 I have a table which requires its primary key as a foreign key to other table, so an unidirectional one-to-one relationship. There will be only an author per book, like this: @Entity public class Author { @Id String code; //getters and setters ... } @Entity public class Book { @Id @OneToOne @JoinColumn(name="code", columnDefinition="DOM_COD5") Author author; //getters and setters } With plain Hibernate and JPA annotations it works well, but using using it through Spring Data I keep getting

Multiple keyspace support for spring-data-cassandra repositories?

筅森魡賤 提交于 2020-01-22 09:57:13
问题 Does Spring Data Cassandra support multiple keyspace repositories in the same application context? I am setting up the cassandra spring data configuration using the following JavaConfig class @Configuration @EnableCassandraRepositories(basePackages = "com.blah.repository") public class CassandraConfig extends AbstractCassandraConfiguration { @Override public String getKeyspaceName() { return "keyspace1"; } I tried creating a second configuration class after moving the repository classes to a

Spring data and junit

ε祈祈猫儿з 提交于 2020-01-17 09:56:09
问题 i have a problem where i want to test spring data with junit. I use spring data jpa with junit 4 : this is my test class @ContextConfiguration(locations={"classpath*:applicationContext.xml"}) @Transactional @RunWith(SpringJUnit4ClassRunner.class) public class EquipementServiceTest1 { @Autowired IEquipementService equipmentservice; @Before public void setUp() throws Exception { equipmentservice=new EquipementService(); } @Test public void testValidateEquipement() { equipementEntity e =new

Spring data and junit

痴心易碎 提交于 2020-01-17 09:49:04
问题 i have a problem where i want to test spring data with junit. I use spring data jpa with junit 4 : this is my test class @ContextConfiguration(locations={"classpath*:applicationContext.xml"}) @Transactional @RunWith(SpringJUnit4ClassRunner.class) public class EquipementServiceTest1 { @Autowired IEquipementService equipmentservice; @Before public void setUp() throws Exception { equipmentservice=new EquipementService(); } @Test public void testValidateEquipement() { equipementEntity e =new

Spring Boot, Thymeleaf Form Error

。_饼干妹妹 提交于 2020-01-17 09:16:03
问题 I am trying to create a task creation page. There is a form where the user can enter the name, description and task status and save it. However, when I go to the page it shows me this error There was an unexpected error (type=Internal Server Error, status=500). Error during execution of processor 'org.thymeleaf.spring4.processor.attr.SpringInputGeneralFieldAttrProcessor' (index) I also have a delete task in my program and that seems to work perfectly fine. This is what my mainController looks

Display data from related entities to avoid the lazy initialization exception with setting up @BatchSize

不问归期 提交于 2020-01-17 08:11:13
问题 I have Entity like that @Entity @Table(...) public class ENTITY_1 { //.... private ENTITY_2 entity_2 ; private ENTITY_3 entity_3 ; private Set<ENTITY_3> entities_3 = new HashSet<ENTITY_3>(0); ; private ENTITY_4 entities_4 = new HashSet<ENTITY_4>(0); ; //... and i want to display a result of a query in my jsp so i make a request with fetch to get all the related entities to avoid the lazy initialization exception left join fetch . My request is based on my ENTITY_1 ( select .. from ENTITY_1 )

spring-data-redis with @Cachable & @Query gives a java.io.NotSerializableException on DefaultMethodInvokingMethodInterceptor

独自空忆成欢 提交于 2020-01-17 07:14:10
问题 When using redis as a cache and @Query on a repository method, redis JdkSerializationRedisSerializer , is unable to serialize a projection. Put a github project with tests; https://github.com/varunmehta/spring-cache-error Actual Entity @Entity public class User { @Id private Integer id; private String firstname; private String lastname; private String email; private String address1; private String address2; private String city; private String state; private String country; // ... setter

How to insert data to table on spring boot application start?

拟墨画扇 提交于 2020-01-17 05:29:12
问题 How can I insert data to a table on Spring Boot application start? My application is generated by JHipster . What I need to check is that if that particular data already exist in that table or not. If it doesn't I should add it. 回答1: You can implement an ApplicationRunner and use a repository to do whatever you need to do. If the ApplicationRunner is a spring bean it is run on application startup. For more sophisticated requirements I would try to rely on a tool like flyway that has good