Click here to Skip to main content
15,892,674 members

Comments by Mohit Tomar (Top 19 by date)

Mohit Tomar 25-Oct-22 5:17am View    
Yes there is ManyToMany annotation but the problem is not due to that. As I also tried running the application after removing all the relation annotations from all the classes and leaving only ID property in each of the pojo class. Still Order Table was not created while other tables were created with only one column i.e. ID. I have also observed that when tables are not present in the dB then also I get the same error (i.e. on the first run) but when I rerun the application it doesn't give any error. I'm not sure if this problem is due to some kind of cache or temporary file that STS maintains. I'm totally confused why I'm getting this error. Any clarification would be much appreciated. Thanks in advance.
Mohit Tomar 25-Oct-22 5:14am View    
Thank you for mentioning that, I didn't know such a feature was present.
Mohit Tomar 25-Oct-22 3:59am View    
Deleted
Both Saleorder and Order contains the same code. Actually I first created Order and when it didn't work I copy and pasted the code in new class Saleorder, and then it worked. Anyways I'm including the code of Order class below

package com.sportyshoes.entities;

import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;

@Entity
@Data
@NoArgsConstructor
@AllArgsConstructor
@ToString
public class Order {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private int id;

@ManyToOne(cascade = CascadeType.ALL)
private Customer customer;

@ManyToMany(cascade = CascadeType.ALL)
private List<product> products;
}
Mohit Tomar 25-Oct-22 3:58am View    
Deleted
Both Saleorder and Order contains the same code. Actually I first created Order and when it didn't work I copy and pasted the code in new class Saleorder, and then it worked. Anyways I'm including the code of Order class below

package com.sportyshoes.entities;

import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;

@Entity
@Data
@NoArgsConstructor
@AllArgsConstructor
@ToString
public class Order {
	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	private int id;
	
	@ManyToOne(cascade = CascadeType.ALL)
	private Customer customer;
	
	@ManyToMany(cascade = CascadeType.ALL)
	private List<Product> products;
}

Mohit Tomar 19-Mar-21 23:43pm View    
Thanks for posting the link. After reading, things are making more sense now.