Java Dependency issue, not working for hibernate -
hello trying follow tutorial ::http://www.tutorialspoint.com/hibernate/hibernate_annotations.htm
my code in caseyou want have dig here: https://github.com/arthurgibbs/centaurus-
im using restx framework.
i trying use hibernate access local database. when try compile code dependency error:
src/main/java/centaurus/service/userdao.java:7: error: package org.hibernate not exist import org.hibernate.hibernateexception;
but have included in pom dont understand why getting error.
this class there error points package centaurus.service;
import centaurus.entity.gameuser; import restx.factory.component; import org.hibernate.hibernateexception; import org.hibernate.session; import org.hibernate.transaction; import org.hibernate.cfg.annotationconfiguration; import org.hibernate.sessionfactory; @component public class userdao { private static sessionfactory factory; public static void main(string[] args) { try{ factory = new annotationconfiguration(). configure(). //addpackage("com.xyz") //add package if used. addannotatedclass(gameuser.class). buildsessionfactory(); }catch (throwable ex) { system.err.println("failed create sessionfactory object." + ex); throw new exceptionininitializererror(ex); } userdao me = new userdao(); } /* method create employee in database */ public integer addemployee(string email){ session session = factory.opensession(); transaction tx = null; integer employeeid = null; try{ tx = session.begintransaction(); gameuser employee = new gameuser(); employee.setemail(email); employeeid = (integer) session.save(employee); tx.commit(); }catch (hibernateexception e) { if (tx!=null) tx.rollback(); e.printstacktrace(); }finally { session.close(); } return employeeid; } public void saveid() { addemployee("bob"); } }
new hibernate, , not experienced maven. please or let me know how me. in advance
as using restx, not read pom, reads md.restx.json file missing dependencies dependancies
Comments
Post a Comment