I am developing a three-tier Java enterprise application in NetBeans, the architecture includes a model for tables, a facade for table interactions, JavaBeans as controllers, and XHTML web pages for display.
I have a "Booking" table generated from an entity class with primary key ID, status, and date. I need to add new columns (FOOD, SEATS, and RATING), but doing so led to the following error when navigating to a webpage that calls objects from the table.
Internal Exception: java.sql.SQLSyntaxErrorException: Column 'FOOD' is either not in any table in the FROM list or appears within a join specification and is outside the scope of the join specification or appears in a HAVING clause and is not in the GROUP BY list. If this is a CREATE or ALTER TABLE statement then 'FOOD' is not a column in the target table. Error Code: 30000
Based on the error message I am getting, I'd assume the issue is Java is not creating the new columns on the existing Booking table. How can I solve this?
I found this question which is similar to my issue. However I am using javax persistence and not eclipse. How can I add another column to my table without dropping it entirely?
I have the following line in my persistence.xml, however the new column is still not generated
<property name="javax.persistence.schema-generation.database.action" value="create"/>
I have also tried labelling the column names on my variable declaration in my model as shown below though it does not seem to do anything as the columns were not generated in the first place.
public class Booking implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "ID")
private Long id;
@Temporal(TemporalType.DATE)
private Date bookingDate;
private String status;
@Column(name = "FOOD")
private String food;
@Column(name = "SEATS")
private Long seats;
@Column(name = "RATING")
private Long rating;
@Column(name = "REVIEW")
private String review;
private Long assignedKitchenStaffId;
private Long customerId;
@JoinColumn(name = "ASSIGNEDKITCHENSTAFF_ID")
@ManyToOne
private User assignedKitchenStaff;
@JoinColumn(name = "CUSTOMER_ID")
@ManyToOne
private User customer;