~.. />com.mysql.cj.jdbc.exceptions.sqlexceptionsmapping.translateException(sqlexceptionsMapping.java:122)
~ 2Mysql-connector-J-8.0.33.jar:8.0.33] at
com.mysql.cj.jdbc.clientprepararedStatement.executeInternal(clientPrepararedStatement.java:916)
~-2mysql-connector-J-8.0.33.jar:8.0.33] bei
com.mysql.cj.jdbc.clientprepararedStatement.executeQuery(clientprepararedStatement.java:972)
~.. />com.zaxxer.hikari.pool.proxyPrepararedStatement.executeQuery(ProxyPrepararedStatement.java:52)
~.. />com.zaxxer.hikari.pool.hikariproxyprepararedStatement.executeQuery(hikariproxyPrepararedStatement.java)
~..hikaricp-5.1.0.jar:na] at
org.hibernate.sql.results /> < /blockquote>
Verwendete Versionen < /strong> < /p>
MySQL Server: 8.0.39 < /li>
Mysql-Anschluss: 8.0.31 < /li>
jakarta.Peristence-apli. />
Code: Select all
@Service
public class UserPreferencesImpl implements UserService {
@Autowired
UserPreferencesRepo userPreferenceRepo;
@Override
public StatusResponse addOrUpdateUserPreferences(){
UserPreferences npe = new UserPreferences();
User user = new User ();
user.setUserId("sampele-user-id");
ne.setUser(user);
userPreferenceRepo.save(ne);
}
}
< /code>
Repo -Klasse < /p>
public interface UserPreferencesRepo extends JpaRepository {
}
Code: Select all
@AllArgsConstructor
@NoArgsConstructor
@Data
@Entity
@Table(name = "user_preferences")
public class UserPreferences implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "up_id", unique = true, nullable = false)
private String upId;
@OneToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "User_Id")
private User user;
}
Code: Select all
@AllArgsConstructor
@NoArgsConstructor
@Getter
@Setter
@Entity
@Table(name = "user")
public class User implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@Column(name = "User_Id", unique = true, nullable = false, length = 64)
private String userId;
@Column(name = "First_Name", length = 128)
private String firstName;
@Column(name = "Last_Name", length = 128)
private String lastName;
}
< /code>
Beschreiben Sie user_preferences
| Feld | Typ | NULL | Schlüssel | Standard | Extra |
|: ---- |: ------: | ------: |: ---- |: ------: | ------: |
| up_id | Bigint | Nein | Pri | [NULL] | auto_increment |
| User_id | varchar (64)
Beschreiben Sie Benutzer
| Feld | Typ | NULL | Schlüssel | Standard | Extra |
|: ---- |: ------: | ------: |: ---- |: ------: | ------: |
| User_id | varchar (64) | Nein | Pri | [NULL] | |
| First_Name | varchar (64) | Ja | Uni | [NULL] | |
| Last_name | varchar (64) | Ja | Uni | [NULL] | |