column "client_id" of relation "payments" does not exist

hey guys. can smb help me out? in my java project i have this entity:
@Data
@Entity
@Table(name="payments")
public class Payment {
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
private Long id;

@NotNull(message="transactionId cant be null")
@Size(max=100,message = "transactionId too long")
private String transactionId;

@NotNull(message="clientId cant be null")
@Size(max=32,message = "clientId too long")
private String clientId;

@Positive
@DecimalMax(value = "99999.99")
@Digits(integer = 5, fraction = 2)
private BigDecimal amount;

@NotNull(message="signature cant be null")
@Size(max=200,message = "signature too long")
private String signature;
}
@Data
@Entity
@Table(name="payments")
public class Payment {
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
private Long id;

@NotNull(message="transactionId cant be null")
@Size(max=100,message = "transactionId too long")
private String transactionId;

@NotNull(message="clientId cant be null")
@Size(max=32,message = "clientId too long")
private String clientId;

@Positive
@DecimalMax(value = "99999.99")
@Digits(integer = 5, fraction = 2)
private BigDecimal amount;

@NotNull(message="signature cant be null")
@Size(max=200,message = "signature too long")
private String signature;
}
and in my service i just use this:
paymentRepository.save(payment);
paymentRepository.save(payment);
and in my db my column is called: clientId. and i keep getting error:
org.postgresql.util.PSQLException: ERROR: column "client_id" of relation "payments" does not exist
Position: 40
org.postgresql.util.PSQLException: ERROR: column "client_id" of relation "payments" does not exist
Position: 40
Can smb help me out? thx
8 Replies
JavaBot
JavaBot5mo ago
This post has been reserved for your question.
Hey @bambyzas! 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 closed 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.
tjoener
tjoener5mo ago
Well, your table payments does not have a column client_id
bambyzas
bambyzasOP5mo ago
i know. but why is my app expecting client_id column?
tjoener
tjoener5mo ago
... because of the clientId field
Tomasm21
Tomasm215mo ago
if in application.properties you have spring.jpa.hibernate.ddl-auto=update and you don't have column in database but you have just added clientId then hibernate should create that column and your table should be updated in database. with update the schema is updated. for me in MySQL created without your error. delete clientId. Let client_id to be created
tjoener
tjoener5mo ago
Never, ever, set ddl-auto to anything other than create-drop if you're just starting your project, or disabled when you have it running in production You should write migrations yourself
Tomasm21
Tomasm215mo ago
I guess he is in development
JavaBot
JavaBot5mo ago
💤 Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived. If your question was not answered yet, feel free to re-open this post or create a new one. In case your post is not getting any attention, you can try to use /help ping. Warning: abusing this will result in moderative actions taken against you.
Want results from more Discord servers?
Add your server