Questions tagged [spring-boot-jpa]
96 questions
0
votes
1 answer
Spring boot jpa identity, ids of new rows jumped forward by 10K
I'm using spring boot JPA 2.1.18. All my model classes derives from this base class:
@Getter
@Setter
@MappedSuperclass
@EntityListeners(AuditingEntityListener.class)
public abstract class DbEntity {
@Id
@GeneratedValue(strategy =…

S-Wing
- 485
- 6
- 25
0
votes
1 answer
Spring boot JPA composite foreign key mapping
I am having trouble setting up jpa mappings for some entities. Below is the scenario I want to implement.
There are 3 tables :
Users: stores the user information. ( Auto Generated Id is Primary key )
Posts: stores the Feed posted by a company. (…

Vishal Tank
- 153
- 2
- 7
0
votes
1 answer
Spring Boot JPA Select Specific columns result should JSON Format
Spring Boot JPA select Specific Columns result should in JSON Format
@Query(value = "SELECT id, property_id, display_name FROM property_basic_property_details WHERE status='1' and unique_id=:unique_id", nativeQuery = true)
public List…
0
votes
1 answer
One To Many Bidirectional relationship implementation postgres SpringBoot
I am seeking the suggestion for implementation of Many-to-One mapping classes and was hoping if anyone could provide me a clear picture.
One to One mapping Scenario: Table foo and Table childfoo Foo has one to many and many to one relationship
Here…

user6090970
- 185
- 1
- 3
- 14
0
votes
1 answer
How using spring-boot-starter-jpa in custom spring-boot-starter?
I have my custom starter. Inside it, I define a repository. How should I define it in the configuration? This is how I did the usual bean before.
@Bean
@ConditionalOnMissingBean(HelloWorldController.class)
public HelloWorldController…
0
votes
1 answer
Convert to DTO from join selection
I have these two tables
And I am using this query to get the results
@Query(value = "SELECT bet.bet, match.name, match.week FROM bet INNER JOIN match ON match.id=bet.match_id WHERE match.week = ?1", nativeQuery = true)
List

Vasil Emilov
- 47
- 8
0
votes
1 answer
How do i check if a record already exists in table in springboot JPA?
I have a table with 4 fields. And if i inserted a record that already exists i.e all field value matches with previous record in table. How do i return record only but not insert into database ?
My model look like this:
@Entity
public class…

Milan Budhathoki
- 61
- 2
- 3
- 7
0
votes
2 answers
Find parent element by searching child / Spring boot JPA + PostgresSQL
I am trying to figure out how to find and return all Books that are associated with a specific author name.
{
"bookId": 5,
"bookName": "test2",
"publishYear": 2022,
"publisher": "test2",
"authors": [
{
"id":…

Alohas
- 21
- 5
0
votes
1 answer
Why does the Spanner spring demo running against the Spanner emulator fail to create pooled database connections?
I'm unable to get Google's spring-data-jpa-sample project running against the Spanner emulator. I'm using a pre-installed JDK 11 (AdoptOpenJDK build 11.0.3+7) on MacOS Mojave.
I've authenticated against my GCP account and gone through the emulator…

Phil Haigh
- 4,522
- 1
- 25
- 29
0
votes
0 answers
SQLSyntaxErrorException for executing native SQL IN clause query in Spring boot JPA
I am using MySql Database. I like to write a native query on 'tbl_users'. I wrote the query like below:
@Query(nativeQuery = true, value = "SELECT * FROM tbl_users AS u WHERE u.id IN (:ids)")
List findByUserIdIn(@Param("ids") Set…

Subarata Talukder
- 5,407
- 2
- 34
- 50
0
votes
1 answer
why does spring throw me an exception about bad sql code?
Im working in an app that has a spring boot server. the thing is that i have a query, not auto generated one, that throws me a bad sql exception and i cant seem to find out why.
Also im using MySQL as a database
this is my repository code…

Goncalo Condeco
- 158
- 12
0
votes
0 answers
Fetching custom fields using spring data jpa
I have relationship between 4 tables, A has B, C, D.
B having many to many relationship with A and C having onetomany with B and D has one-to-one with A.
Now how to fetch only a1, b1, c2, d1&d2 columns using spring data jpa.

Prince
- 33
- 1
- 8
0
votes
1 answer
Spring Boot 2 - JPA + Pagable problem on ManyToMany tables
In Spring Boot 2 JPA, I have the following two many to many Entities.
1- Labor:
@Entity
public class Labor {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private long id;
@Column(length = 100, nullable = false)
…

Korben
- 734
- 1
- 7
- 26
0
votes
1 answer
cause.getConstraintName() returning a weird string instead of actual constraint name
I have a column set to as unique = true.
Here is the code of my entity -
@Entity
@Table(name = "users", uniqueConstraints=[UniqueConstraint(name = "userName", columnNames=["user_name"])])
class UserEntity(@Column(name = "user_id", nullable = false)
…

krtkush
- 1,378
- 4
- 23
- 46
0
votes
1 answer
Implementing complex MAX function in Spring Boot/JPA query language
Spring Boot here using JPA/Hibernate and CrudRepository impls for managing persistence to my DB tables.
I have the following MySQL table:
CREATE TABLE IF NOT EXISTS price_scarcity_configs (
price_scarcity_config_id BIGINT UNSIGNED NOT NULL…

hotmeatballsoup
- 385
- 6
- 58
- 136