unit to test a mock interface implementation in Spring Boot

I'm trying to write a simple unit test for a service in Spring Boot. The service calls a method on a repository which returns an instance of User. I'm trying to mock the repository, because I want to test only the service. So, the code for Repository

Hibernate HQL could not locate the named parameter

users = (List<User>) currentSession.getCurrentSession().createQuery("FROM User as u " + " LEFT JOIN FETCH u.tests as p" +" WHERE u.registrationDate BETWEEN " +"':tenDaysBeforeDate' AND ':currDate' " +"ORD

@EnableAspectJAutoProxy does not work

I am using Spring Boot, and I would like to use AspectJ with it. The following works (of course): @Aspect @Component public class RequestMappingAspect { @Before("@annotation(org.springframework.web.bind.annotation.RequestMapping)") public void a

Spring start form template

I've a number of posts re this issue but non worked. I have a model class Role of which i am trying to create a new one from an HTML form but i am getting IllegalStateExcepion. I recreated an example found on the Spring site but also didn't work with

Default value for the user role - Spring security

I'm trying to add a default role value when the user register in Spring Security. I have two models "User" and "Role" linked with a many-to-many relation. User.java @NotEmpty @ManyToMany(fetch = FetchType.EAGER, cascade = CascadeType.A

Spring ORM (hibernation) vs hibernation

I have used hibernate in my java project where I have used Spring MVC. I avoided SPRING HIBERNATE because it seemed that it was making my code very tightly coupled. Now, even if I move the app to struts, my service layer would work fine (because I ha

Spring form field dataType conversion, error

This is Achinta, a new bee in the world of Spring. I need a small help to understand and resolve a problem which I am facing. I hope will find my answer here. I am working on a sample Spring Web project. Here I have a Controller, Bean class and a Jsp

Maven module using a starter spring

I like to configure my applications in maven by creating modules like; <groupId>com.app</groupId> <artifactId>example-app</artifactId> <version>0.0.1-SNAPSHOT</version> <packaging>pom</packaging> <modules

How to get the float value in ResultSet from Hibernate Query?

I have the following query select sum(r.score)/count(r) from Rating as r group by r.item order by sum(r.score)/count(r) desc My problem is that hibernate rounds the result sum(r.score)/count(r). How can I force Hibernate to return the float value of

Spring applications failed, Autowire is null in main.class

i am using netbeans 7.2, postgres sql,jpa2,hibernate 4.2. i just created a new maven simple java project(not webapp). However i have done setup hibernate and jpa,but autowire "wpService" get null(not sure is it caused by hibernate configuration)

download the Spring file using ResponseBody

Hello i'm trying create an application allowing me host any kind of file. In order to do it i'm exececuting following magic: @RequestMapping(value = "/files/{file_name}", method = RequestMethod.GET) @ResponseBody public FileSystemResource getFil

XML does not resume & lt; camelContext & gt; Mark

this is probably a simple mis configuration problem but I am having an issue with my xml document picking up my tag. I am getting the error "Multiple annotations found at this line: - cvc-complex-type.2.4.c: The matching wildcard is strict, but no de

Redirect to https for some services using Spring

I have an application which uses spring (also spring security) where few services were kept outside the secured resource set by specifying like below in the applicationContext.xml: <http pattern="/services/rest/nohisb/Msgs" security="non

Struts + Spring + Hibernate Integration

For example, we have the next bunch: Struts, Spring, Hibernate. Can you help me understand the role played by each of the elements? I know that Hibernate is responsible for all on the database. But, what role Struts and Spring in this case? Thanks.St

Load the spring context into an EJB-based application

The following is the situation : I have a business layer, that is an EJB project. In fact, there is only one EJB that is created. This EJB is responsible to expose the service classes to other layers, that calls the EJB. I want to introduce spring (t

Spring: Make sure a particular bean is initialized first

I have a library doing runtime setup and configuration of log4j (no log4j.properties or log4j.xml). I have defined a bean with class called MyLoggerFactory and I want this to be the first bean to be initialised using spring. I have seen that an issue

Exporting Spring @Bean Objects Using JMX

I'm using Spring's @Configuration, and I noticed that a @Bean does not get registered using JMX. The bean is wired as @Bean protected CountingHttpInterceptor countingHttpInterceptor() { return new CountingHttpInterceptor(); } and the class definition

JSR 303 Bean Validation + Client side validation

What is the best way to perform client-side form validation using Javascript (with minimal code duplication) when using JSR 303 bean validation on the server side? I'm currently using Spring 3 and the Hibernate Validator.I would suggest that you look

How to better modify my model in Spring MVC if I care about IOC

I am building an application using Spring MVC. I want to make certain changes to my Model for every Controller in the application. In particular, I want to insert certain extra data into the model which will be present for all pages of the applicatio