I want to save a student and a student has a TargetAudience object as an attribute. These target audiences are allready hardcoded in my database. (targetaudience = campus + major). Now when i post like this: it doesnt work because everythime it creates a new object for the campus and because i use name as a primary key it throws
Tag: spring
Create relationship between 2 tables JPA
Need help with setting up table relationships. So, there are 2 entities – Section and Period. 1 Section has many Period, but 1 Period do not belongs to any specific Section. I implemented this relationship as follows: created an additional table SectionCodes with an external key on Section (more in diagram) Section class: SectionPeriod: This works fine, but there is
Hibernate – make id value be able to be autogenerated directly in datasource as well
I’m making a Spring boot application with Hibernate ORM framework. I have an @Entity class in my code: I successfully can persist a Thing to my datasource. And thing_id is generated as expected. But I cannot insert a record directly in database manager (e.g. DataGrip): I have a warning and appropriate error when trying to insert: So how can I
Order by 2 columns with case
I have a query that searches for user in 2 colums firstUser and secondUser and orders them by first and last name: But this first orders the cases when user is at first user then it orders the case when user is secondUser. Is ther a way to order the whole data by first name and last name no matter
Is NamedParameterJdbcTemplate vulnerable safe?
We are using NamedParameterJdbcTemplate to achieve “IN” operator functionality. Is there any SQL Injection vulnerability when we use NamedParameterJdbcTemplate? Answer Since NamedParameterJdbcTemplate internally use PreparedStatement for querying , and if you can make sure that you do not build the SQL query by somehow concatenating the input from the user , but using the placeholder :xxxx to specify their value,
Error starting Tomcat context.Exception: org.springframework.beans.factory.BeanCreationException.Message:Error creating bean with name ‘h2Console’ def
I have this simple CRUD Spring HTTP Service (see ). I would like to achieve something like . I made use of Thymeleaf and 2 html files: add-edit-employee.html and list-employees.html. Initial data comes from an sql table: data.sql & schema.sql. When I run the project I get error: Log of the errors 2 Pom file application.properties EmployeeEntity class data.sql schema.sql
How to import data from one table to another – SpringBoot JPA /MySQL
I recently created a vehicle management system The system is derived from MySQL database and server side in spring I want to create another table (automatically at runtime) that will display only 2 of the columns of the existing table. And the question is what am I doing wrong? Final goal – when adding / deleting / editing a vehicle,
Boolean value not being changed in database
Hey folks I’m having a problem with my code. For some reason when I try to change the value to false, it doesn’t reflect in my SQL Database. I debugged and it does get set via Java, but it doesn’t transfer over. I’m working on a notification service class and it sets the values on there to true no problem,
SQL Grammar Exception in Spring Boot H2
I’v got a problem in my Spring Boot with H2 project. I got a get method for listing elements from the SQL table and the SQL command working. In the H2 database I can execute and see the results but I …
JpaRepository SQL syntax error when trying to save to MySQL Date
I have the following row in my MySQL Table: https://i.stack.imgur.com/u0FC4.png This column is represented as: And it is bound to a Thymeleaf form like so: Now if I insert a date into the MySQL db directly, the date is loaded and set to the correct date on the form: https://i.stack.imgur.com/e35lr.png But every time I try to save or edit the