Код: Выделить всё
code 1:
Код: Выделить всё
package com.scm.entities;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import lombok.*;
@Entity(name = "user") // doing this makes sure that we have to create a table out of it
@Table(name = "users") // we can set the name of table
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class User {
@Id // this sets userId as primary key
private String userId;
@Column(name = "user_name", nullable = false) // this sets the column name as 'user_name' for the name field
private String name;
@Column(unique = true, nullable = false)
private String email;
private String password;
@Column(length = 10000)
private String about;
@Column(length = 10000)
private String profilePic;
private String phoneNumber;
// information
private boolean enabled=false;
private boolean emailVerified = false;
private boolean phoneVerified = false;
// logged in themselves or using google, linkedin, github or others
private final Providers provider=Providers.SELF;
private String providerUserId;
}
Код: Выделить всё
code 2:
Код: Выделить всё
package com.scm.entities;
import jakarta.persistence.*;
@Entity
@Table(name = "users") // Name of the table in the database
public class User {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(nullable = false)
private String username;
@Column(nullable = false, unique = true)
private String email;
}
ОБНОВЛЕНИЕ: Думаю, я нашел решение: размер атрибута в таблице был слишком большим, поэтому я изменил его с 10 000 на 1000, и теперь он работает.
Подробнее здесь: https://stackoverflow.com/questions/786 ... rent-codes