i have "A" entity with List<String> MyList
:
@Entity(name = "A_table")
@Inheritance(strategy=InheritanceType.JOINED)
public class A implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
private String RepresentativeName;
@ElementCollection
@CollectionTable(name = "MyList_Table")
private List<String> MyList;
}
After i set Values to this "A" entity, i want to delete all this data from the derby table.
But how i can delete the Strings from the CollectionTable (MyList_Table)?
I try to make it by HQL query, but i got error.
List<String> strList = em.createQuery("from MyList_Table").getResultList();
...
...
the Error:
MyList_Table is not mapped [from MyList_Table]
How should I formulate the query correctly?
There may be another way to delete this CollectionTable data?
--------------------------------
Update:
when i used :
List<A> objectList = em.createQuery("from A_table").getResultList();
-> i got error :
A_Table is not mapped [from A_Table]
.
So I decided to leave this line as it was:
List<A> objectList = query.getResultList()
.
But then, if i try to delete it:
for (A a:objectList)
{
if(....)
{
List<String> Mylist = a.getMyList();
em.getTransaction().begin();
em.remove(Mylist);
em.getTransaction().commit();
}
}
i get an error :
org.hibernate.MappingException: Unknown entity: org.hibernate.collection.PersistentBag
So i try to add "@IndexColumn
" annotation :
.....
@ElementCollection
@CollectionTable(name = "A_Table")
@IndexColumn(name= "indx")
private List<String> MyList;
...
and now i get this error:
org.hibernate.MappingException: Unknown entity: org.hibernate.collection.PersistentList
what i should do?
Thank you very much!!