}
return userdata;
}
public Userdata getUserdataByKey(Long user_id, String DATA_KEY) {
Userdata userdata = new Userdata();
if (user_id.longValue() > 0) {
try {
Object idf = PersistenceSessionUtil.createSession();
EntityManager session = PersistenceSessionUtil.getSession();
EntityTransaction tx = session.getTransaction();
tx.begin();
Query query = session
.createQuery("select c from Userdata as c where c.user_id = :user_id AND c.data_key = :data_key AND c.deleted <> :deleted");
query.setParameter("user_id", user_id.longValue());
query.setParameter("data_key", DATA_KEY);
query.setParameter("deleted", "true");
for (Iterator it2 = query.getResultList().iterator(); it2
.hasNext();) {
userdata = (Userdata) it2.next();
}
tx.commit();
PersistenceSessionUtil.closeSession(idf);
} catch (Exception ex2) {
log.error("getUserdataByKey", ex2);
}
} else {
userdata.setComment("Error: No USER_ID given");
}
return userdata;
}