types don t mtach the db in springboot backend

dunno what would be a handy way to fix it
5 Replies
JavaBot
JavaBot6mo ago
This post has been reserved for your question.
Hey @Timo! Please use /close or the Close Post button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically marked as dormant after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
Timo
TimoOP6mo ago
INSERT INTO event (
duration, registration_amount, start_time, description,
location, title, image
) VALUES (
'60 min', 10, '2025-06-20 10:00:00',
'Kom de oude fabrieken ontdekken', 'Amsterdam', 'Westerpark',
'/images/Westerpark.avif'
);
INSERT INTO event (
duration, registration_amount, start_time, description,
location, title, image
) VALUES (
'60 min', 10, '2025-06-20 10:00:00',
'Kom de oude fabrieken ontdekken', 'Amsterdam', 'Westerpark',
'/images/Westerpark.avif'
);
package com.example.backend.models;

import jakarta.persistence.*;
import lombok.*;

import java.time.Duration;
import java.time.LocalDateTime;
import java.util.List;
import java.util.UUID;

@Entity
@Data
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "event")
public class Event {
@Id
@GeneratedValue(strategy = GenerationType.UUID)
private UUID eventsId;

@Column
private String title;

@Column
private String description;

@Column
private String location;

@Column
private LocalDateTime startTime;

@Column
private String duration;

@Column
private Integer registrationAmount;

@Column
private byte[] image;

@ManyToOne
@JoinColumn(name = "podwalk_id")
private Podwalk podwalk;

@OneToMany(mappedBy = "event")
private List<EventRegistration> registrations;
}
package com.example.backend.models;

import jakarta.persistence.*;
import lombok.*;

import java.time.Duration;
import java.time.LocalDateTime;
import java.util.List;
import java.util.UUID;

@Entity
@Data
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "event")
public class Event {
@Id
@GeneratedValue(strategy = GenerationType.UUID)
private UUID eventsId;

@Column
private String title;

@Column
private String description;

@Column
private String location;

@Column
private LocalDateTime startTime;

@Column
private String duration;

@Column
private Integer registrationAmount;

@Column
private byte[] image;

@ManyToOne
@JoinColumn(name = "podwalk_id")
private Podwalk podwalk;

@OneToMany(mappedBy = "event")
private List<EventRegistration> registrations;
}
\ Caused by: org.postgresql.util.PSQLException: ERROR: null value in column "events_id" of relation "event" violates not-null constraint Detail: Failing row contains (10, 2025-06-20 10:00:00, null, null, Kom de oude fabrieken ontdekken, 60 min, Amsterdam, Westerpark, \x2f696d616765732f5765737465727061726b2e61766966). normally the model would just create a uuid do i need to put a random one there for now?
Timo
TimoOP6mo ago
No description
Timo
TimoOP6mo ago
fixed it gen a random uuid with sql !close
JavaBot
JavaBot6mo ago
Post Closed
This post has been closed by <@591288621345275915>.

Did you find this page helpful?