idomiralin
How to insert data from textfields into database using hibernate?
0 Answer(s)      2 years and 11 months ago
Posted in : Java Beginners

try{ Session session = HibernateUtil.getSessionFactory().openSession(); org.hibernate.Transaction tx = session.beginTransaction(); Produs produs = new Produs(); produs.setIdprodus("IdProdusTextField"); produs.setFurnizor("IdFurnTextField"); produs.setCategorie(IdCatTextField); produs.setRaft(IdRaftTextField); produs.setDenumire(DenumireTextField); produs.setCantitate(IdCantitateTextField); produs.setUnitMas(UnitMasTextField);

    session.save(produs);
    System.out.println("Successfully data insert in database");
    tx.commit();

}

This method doesn't work. I tried with quotes for textfields, without them. The setters require other parameters, not textfields. I tried to cast them, but it doesn't work either.

Maybe you can help me. Thanks!

Advertisement
View Answers









Related Tutorials/Questions & Answers:
Advertisements