Skip to content
Advertisement

Tag: spring-data-jpa

How to Map a JPA create native query to projections

I am trying to get count from a postgreSQL database using Spring Data JPA createNativeQuery. However, the query is returning null instead of the actual values. Here is the JPA createNativeQuery statement below: I need help mapping the “submitted”, “pending” and “totalApplications” instances from my query in a way that returns the result as below. Result expected is: Result am

Spring Data JPA Distinct Returning Duplicate Values

In my Spring boot application I have a query which should return a distinct List of Focus’ (works perfectly in MySQL) However this does not return distinct values, duplicates are contained in the resulting list. Another issue is that I can’t return a whole entity using @Query annotation – changing my query to SELECT DISTINCT(F) FROM Focus F gives the

Spring JPA-I get error that object is not persisted even though i have persisted it

I am using Spring boot-I have 3 classes User,Role and UserRole.I have pesisted both role object and user object but i get error that role object is not persisted.The mappings- between User and UserRole is OneToMany ,between Role and UserRole OneToMany.In the UserServiceImpl class i have persisted Role object roleRepository.save(userRole.getRole()); Error is- Answer Couple of issues here. The first (and

post data for foreign key in postman

this is my model class.There is foreign key from another table AssessmentProperties .now when iam posting the data with postman my data looks like this but my input should be looking like this can anyone say me what should i do for this? and by the way this is the controller for post method Answer Instead of using SectionProperties as

Escape colon (‘:’) in custom h2 Query

So I am trying to write a custom query for h2 using its JSON_OBJECT function. JSON_OBJECT uses a format of JSON_OBJECT(key:value) so as a simple example in my Spring repository I am writing a query like @Query(value = “SELECT JSON_OBJECT(‘id’:1)”, nativeQuery = true) When executing that same query in the h2-console it operates as expected but in Spring the colon(‘:’)

What’s the effective way to insert more a million rows into postgresql server from another postgres server using Java?

I have two postgresql servers and I need to copy table rows with from first server format and convert to another server format (different column names). I use java application with spring boot and jpa repository, which implemented method findAll with stream read fetch size 1000. After reading I convert and insert 1000 rows in batch. For my opinion, current

Advertisement