#non existent query??
1 messages · Page 1 of 1 (latest)
<@&1004656351647117403> please have a look, thanks.
Here is an AI assisted attempt to answer your question 🤖. Maybe it helps! In any case, a human is on the way 👍. To continue talking to the AI, you can use </chatgpt:1108714622413963314>.
there is no specific query mentioned in your question. However, based on the information provided, it seems like you are facing an issue with linking two models through many-to-one and one-to-many annotations.
To resolve this issue, you can follow these steps:
-
Make sure that you have properly defined the relationships between the two models using the appropriate annotations (e.g., ForeignKey, OneToManyField).
-
Check if you have correctly set up the related_name parameter in the ForeignKey or OneToManyField annotations. This parameter allows you to specify a custom name for the reverse relation from the related model back to the current model.
-
Verify that you have saved any changes made to your models and run any necessary migrations to update your database schema.
-
Double-check your code to ensure that you are accessing the related objects correctly. For example, if you have a many-to-one relationship from Model A to Model B, make sure you are using
model_a.model_bormodel_a.model_b_set.all()to access the related objects.
If none of these steps resolve your issue, please provide more specific details about the error message or code snippet causing the problem so that we can assist you further.
Request processing failed: org.springframework.dao.InvalidDataAccessResourceUsageException: JDBC exception executing SQL [select ud1_0.user_id,ud1_0.email,ud1_0.is_admin,ud1_0.password,ud1_0.subscription,ud1_0.username from commentary ud1_0]
Hey there!
Would you like to share your 2 entities code pls, to help us figure out
yes, one sec
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.query.Order;
import java.util.ArrayList;
import java.util.List;
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@Entity
@Table(name = "commentary")
public class UserD {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name="id", nullable=false, updatable=false)
private Long id;
@Column(name = "username")
private String username;
@Column(name = "email")
private String email;
@Column(name = "password")
private String password;
@Column(name = "subscription")
private boolean subscription;
@Column(name = "is_admin")
private boolean isAdmin;
@OneToMany(fetch = FetchType.EAGER, mappedBy = "userDCom")
private List<CommentaryD> comments = new ArrayList<>();
@OneToMany(fetch = FetchType.EAGER, mappedBy = "userDNotif")
private List<NotifD> receivedNotifs = new ArrayList<>();
@OneToMany(fetch = FetchType.EAGER, mappedBy = "userDOrder")
private List<OrderD> orders = new ArrayList<>();
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import net.minidev.json.annotate.JsonIgnore;
import java.util.Date;
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@Entity
@Table(name = "commentary")
public class CommentaryD {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name="commentary_id", nullable=false, updatable=false)
private Long id;
@Column(name = "content")
private String content;
@Column(name = "date")
private Date date;
@ManyToOne
@JoinColumn(name = "user_id")
@JsonIgnore
private UserD userDCom;
@ManyToOne
@JoinColumn(name = "event_id")
@JsonIgnore
private EventD eventDCom;
there they are, not full code but there are just getters and setters left
i forgot to add column to which many to one are referencing to, but even after that it is still the same
please use
Please use this format for posting code:
```java
// Example java program
int value = 5;
System.out.println(value);
```
Which results in:
// Example java program
int value = 5;
System.out.println(value);
For syntax highlighting, you have to add the name of the language after the three backticks, like ```java. Please make sure to use exactly this format, so no space between the backticks and the language name, and a newline before the code starts. If done right, the syntax highlighting will even be applied to your text as you type, before sending.
and could you share your repository?