Now to my understanding to map a table in db we add:
@Entity()
@Table(name = "test")
public class Test implements Serializable {
/** Constant - serial version UID. */
public final static long serialVersionUID = 1L;
/** Member variable - represents the "name" field. */
public String name;
}
but for some reason when I do query:
delete from test;
it gives me this error:
15:55:54,140 ERROR [JsonFilter] javax.ejb.EJBException: java.lang.IllegalArgumentException: org.hibernate.hql.ast.QuerySyntaxException: spa_splash_page_ad is not mapped [delete from spa_splash_page_ad]
javax.servlet.ServletException: javax.ejb.EJBException: java.lang.IllegalArgumentException: org.hibernate.hql.ast.QuerySyntaxException: spa_splash_page_ad is not mapped [delete from spa_splash_page_ad]
at com.pinksheets.common.web.servlet.DeleteSplashPageServlet.fetch(DeleteSplashPageServlet.java:30)
at com.pinksheets.common.web.servlet.DeleteSplashPageServlet.fetch(DeleteSplashPageServlet.java:17)
any idea why it is doing that?
delete from table testisn’t a valid query in any QL I know of.A class mapped as
@IdClassis a composite id, and you’d never delete it directly. You would delete an entity that has that as its id. Also since it’s an@IdClass, I’m not sure what to expect when you give it an explicit@Tablemapping. An@IdClassis a primary key value and is always supposed to be used as an id of some other class. It doesn’t have its own table. See the hibernate annotations reference for mapping composite ids and correct use of@IdClass.