How to set UUID as a primary key, and make an entry?

@Table("restaurant_group")
public class RestaurantGroup extends Base {
@Id
@GeneratedValue(strategy = GenerationType.UUID)
private UUID id;
@Table("restaurant_group")
public class RestaurantGroup extends Base {
@Id
@GeneratedValue(strategy = GenerationType.UUID)
private UUID id;
4 Replies
JavaBot
JavaBot4d ago
This post has been reserved for your question.
Hey @Rag...JN 🌌 🦡 👽 💰 🐊! 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.
Rag...JN 🌌 🦡 👽 💰 🐊
So if I tried to do this (without setting UUID manually)
@Override
public Mono<RestaurantGroup> createRestaurantGroup(String userId, RestaurantGroupCreateDTO restaurantGroupCreateDTO) {
RestaurantGroup restaurantGroup = RestaurantGroupMapper.restaurantGroupCreateDTOToRestaurantGroup(restaurantGroupCreateDTO);
// UUID uuid = UUID.randomUUID();
// restaurantGroup.setId(uuid);
return restaurantGroupRepository.save(restaurantGroup);
}
@Override
public Mono<RestaurantGroup> createRestaurantGroup(String userId, RestaurantGroupCreateDTO restaurantGroupCreateDTO) {
RestaurantGroup restaurantGroup = RestaurantGroupMapper.restaurantGroupCreateDTOToRestaurantGroup(restaurantGroupCreateDTO);
// UUID uuid = UUID.randomUUID();
// restaurantGroup.setId(uuid);
return restaurantGroupRepository.save(restaurantGroup);
}
It throws error as null value in column \"id\" of relation \"restaurant_group\" violates not-null constraint" If I tried to set manually (by uncommenting the lines)
Failed to update table [restaurant_group]; Row with Id [d3d8d8dd-305f-4cda-9e69-0d764d66837b] does not exist",
Failed to update table [restaurant_group]; Row with Id [d3d8d8dd-305f-4cda-9e69-0d764d66837b] does not exist",
I use webflux ok I found the solution
JavaBot
JavaBot4d 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