i want id table in database, if try id name, have save in list obj, cant use id table again because object , not integer.
my method update table:
public void updateevent (string eventname, string beschreibung, string datum, string ort) { annotationconfiguration configuration = new annotationconfiguration(); configuration.configure(); sessionfactory sessionfactory = configuration.buildsessionfactory(); session session = sessionfactory.opensession(); transaction transaction = session.begintransaction(); string hql = "select a.eventid admintoolbean a.name = :name"; query query = session.createquery(hql); query.setparameter ("name", eventname); list<admintoolbean> results = (list<admintoolbean>) query.list(); system.out.println(results.get(0)); system.out.println(results.get(1)); system.out.println(results.get(2)); admintoolbean event = (admintoolbean) session.load(admintoolbean.class, results.get(0)); event.setname(eventname); event.setbeschreibung(beschreibung); event.setdatum(datum); event.setort(ort); session.update(event); transaction.commit(); session.close(); }
if need id, not object, use simple jdbc. spring has jdbctemplate, or ibatis/mybatis framework.
Comments
Post a Comment