Custom user is null when i is defined in another tabel with springboot

don t understand why it can t pick the value from the customuser it is just the id so i can match an order to a registered person
14 Replies
JavaBot
JavaBot10mo ago
This post has been reserved for your question.
Hey @timo! 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.
Timo
TimoOP10mo ago
public Order placeOrder(OrderDTO orderDTO, CustomUser customUser) {

final Order order = new Order();
order.setCustomUser(customUser);
order.setStatus("placed");
order.setOrderDate(LocalDate.now());
order.setOrderProducts(new HashSet<>());
orderRepository.save(order);
public Order placeOrder(OrderDTO orderDTO, CustomUser customUser) {

final Order order = new Order();
order.setCustomUser(customUser);
order.setStatus("placed");
order.setOrderDate(LocalDate.now());
order.setOrderProducts(new HashSet<>());
orderRepository.save(order);
public class CustomUser {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

private String firstname;

private String lastname;

private String email;
@Column(name ="password", nullable = false )

private String password;

private UserRole userRole;
public class CustomUser {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

private String firstname;

private String lastname;

private String email;
@Column(name ="password", nullable = false )

private String password;

private UserRole userRole;
Timo
TimoOP10mo ago
No description
No description
Timo
TimoOP10mo ago
like it works but sya s it is null when trying to use it in the other table
Peter Rader
Peter Rader10mo ago
Please improve the quality of the question.
Timo
TimoOP10mo ago
with info do you need?
Peter Rader
Peter Rader10mo ago
I do not understand this question. With me?
Timo
TimoOP10mo ago
just trying to bind the user_id to the order so i know wich user ordered wich products in the backend but says null
Peter Rader
Peter Rader10mo ago
What means kn? What means ow? What means wich?
Timo
TimoOP10mo ago
which
Timo
TimoOP10mo ago
No description
Timo
TimoOP10mo ago
this is null maybe i can try to get it from the repository directly but not sure how because i can t bind it to order
Peter Rader
Peter Rader10mo ago
What means usre? What means t? I am sorry, I might not understand the dialect you are using. Maybe someone else could help you.
JavaBot
JavaBot10mo 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.

Did you find this page helpful?