nullpointerexception - Hibernate null pointer(session) when having a lot of mapping classes -


when i'm inserting object generic dao class im getting null pointer in session, happen when have lot of mapping classes (i have 110 tables in db), if same test same code 10 mapping classes in package mappings/hibernate.cfg program works correctly, looks dao tries go faster hibernate session loading? (it's perfonmance problem?) in advance i'm wasting time solve this.

this hibernate session:

public class hibernatesession {     private static final sessionfactory sessionfactory= buildsessionfactory();     private static session session;      private static sessionfactory buildsessionfactory() {         configuration configuration = new configuration();         configuration.configure();         serviceregistry serviceregistry = new standardserviceregistrybuilder()                 .applysettings(configuration.getproperties()).build();         sessionfactory sessionfactory = configuration.buildsessionfactory(serviceregistry);         return sessionfactory;     }      public static sessionfactory getsessionfactory() {         return sessionfactory;     }      public static session getsession() {         if (null == session || !session.isopen()) {             session = sessionfactory.opensession();          }         return session;     }  } 

insert method:

public void insert(t entity) throws hibernateexception {     try {         starttransaction();         session.persist(entity);         session.flush();     } catch (hibernateexception e) {         handleexception(e);     } {         endtransaction();     } }  protected void starttransaction() {      session = hibernatesession.getsession();     session.begintransaction(); }      protected void endtransaction() {     session.gettransaction().commit();     session.close(); } 

console:

    abr 25, 2016 10:52:59 org.hibernate.engine.jdbc.connections.internal.drivermanagerconnectionproviderimpl configure info: hhh000115: hibernate connection pool size: 20 (min=1) abr 25, 2016 10:53:00 org.hibernate.dialect.dialect <init> info: hhh000400: using dialect: org.hibernate.dialect.oracle10gdialect exception in thread "main" java.lang.nullpointerexception     @ tws.hibernate.dao.genericdao.endtransaction(genericdao.java:58)     @ tws.hibernate.dao.genericdao.insert(genericdao.java:87)     @ twstestrunner.main(twstestrunner.java:26) 

ok, solved it, different exception, not showing in console, see error doing instance of hibernatesession @ start of program, error :

caused by: org.hibernate.annotationexception: mixing nullable , non nullable columns in property not allowed:  

it problem of database, fk wherent marked not nullable hibernate mapping them wrong., program worked when had few tables because correct.


Comments

Popular posts from this blog

javascript - How to get current YouTube IDs via iMacros? -

c# - Maintaining a program folder in program files out of date? -

emulation - Android map show my location didn't work -