@GeneratedValue не генерирует значение, хотя у меня есть последовательность, определенная в Oracle sql ⇐ JAVA
@GeneratedValue не генерирует значение, хотя у меня есть последовательность, определенная в Oracle sql
I have problem with this authentication code
@Service public class UserServiceImpl implements UserService{ private UserRepository userRepository; private PasswordEncoder passwordEncoder; public UserServiceImpl(UserRepository userRepository, PasswordEncoder passwordEncoder){ this.userRepository = userRepository; this.passwordEncoder = passwordEncoder; } @Override public void saveUser(UserDto userDto) { UserInfo userInfo= new UserInfo(); userInfo.setUsername(userDto.getUsername()); userInfo.setEmail(userDto.getEmail()); userInfo.setPassword(passwordEncoder.encode(userDto.getPassword())); userInfo.setRole(userDto.getRole()); userRepository.save(userInfo); } @Override public UserInfo findUserByEmail(String email) { return userRepository.findByEmail(email); } } @Data public class UserDto { private String username; private String email; private String password; private String role; } @Data @Entity @Table(name = "userdetails") public class UserInfo { @Id @GeneratedValue(strategy = GenerationType.SEQUENCE,generator = "seq_id") @SequenceGenerator(name = "seq_id",sequenceName = "seq_id",allocationSize = 1) @Column(name = "id") private int id; /.../ } All the data is correctly stored in UserDto as i checked with logging but there is a problem with id in UserInfo. Im using Oracle SQL and have created sequence that will increment value, but when i use it as follows with @GeneratedValue and @SequenceGenerator it returns me an error
[Request processing failed: org.springframework.dao.InvalidDataAccessResourceUsageException: could not execute statement [ORA-04098: trigger 'LOCALADMIN.USERDETAILS_ID_TRG' is not correct; revalidation failed ] [insert into userdetails (email,password,role,username,id) values (?,?,?,?,?)]; SQL [insert into userdetails (email,password,role,username,id) values (?,?,?,?,?)]] with root cause I tried using different strategies in @GeneratedValue 1)For GenerationType.AUTO i recieve error ORA-02289 sequence doesnt exists 2)For GenerationType.Identity i recieve
could not execute statement [ORA-04098: trigger 'LOCALADMIN.USERDETAILS_ID_TRG' is not correct; revalidation failed ] [insert into userdetails (email,password,role,username,id) values (?,?,?,?,default)]; SQL [insert into userdetails (email,password,role,username,id) values (?,?,?,?,default)]] with root cause
Источник: https://stackoverflow.com/questions/780 ... -in-oracle
I have problem with this authentication code
@Service public class UserServiceImpl implements UserService{ private UserRepository userRepository; private PasswordEncoder passwordEncoder; public UserServiceImpl(UserRepository userRepository, PasswordEncoder passwordEncoder){ this.userRepository = userRepository; this.passwordEncoder = passwordEncoder; } @Override public void saveUser(UserDto userDto) { UserInfo userInfo= new UserInfo(); userInfo.setUsername(userDto.getUsername()); userInfo.setEmail(userDto.getEmail()); userInfo.setPassword(passwordEncoder.encode(userDto.getPassword())); userInfo.setRole(userDto.getRole()); userRepository.save(userInfo); } @Override public UserInfo findUserByEmail(String email) { return userRepository.findByEmail(email); } } @Data public class UserDto { private String username; private String email; private String password; private String role; } @Data @Entity @Table(name = "userdetails") public class UserInfo { @Id @GeneratedValue(strategy = GenerationType.SEQUENCE,generator = "seq_id") @SequenceGenerator(name = "seq_id",sequenceName = "seq_id",allocationSize = 1) @Column(name = "id") private int id; /.../ } All the data is correctly stored in UserDto as i checked with logging but there is a problem with id in UserInfo. Im using Oracle SQL and have created sequence that will increment value, but when i use it as follows with @GeneratedValue and @SequenceGenerator it returns me an error
[Request processing failed: org.springframework.dao.InvalidDataAccessResourceUsageException: could not execute statement [ORA-04098: trigger 'LOCALADMIN.USERDETAILS_ID_TRG' is not correct; revalidation failed ] [insert into userdetails (email,password,role,username,id) values (?,?,?,?,?)]; SQL [insert into userdetails (email,password,role,username,id) values (?,?,?,?,?)]] with root cause I tried using different strategies in @GeneratedValue 1)For GenerationType.AUTO i recieve error ORA-02289 sequence doesnt exists 2)For GenerationType.Identity i recieve
could not execute statement [ORA-04098: trigger 'LOCALADMIN.USERDETAILS_ID_TRG' is not correct; revalidation failed ] [insert into userdetails (email,password,role,username,id) values (?,?,?,?,default)]; SQL [insert into userdetails (email,password,role,username,id) values (?,?,?,?,default)]] with root cause
Источник: https://stackoverflow.com/questions/780 ... -in-oracle
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение