@PersistenceContext
private EntityManager em;
public Tag createTag (String tag){
Tag t = null;
Query q = em.createQuery("select COUNT(t) from Tag t where t.tagName=:tag");
q.setParameter("tag", tag);
int count = Integer.valueOf(q.getSingleResult().toString());
if (count==0){
System.out.println("création de tag");
t = new Tag(tag);
em.persist(t);
}
return t;
}