hibernate - How to load global settings frequently used in application in Java -


1) in application have table stores settings detail used heavily every functionality.basically conditions set in table checked.

now doing making db call every , fetch details , check condition.this has resulted in lot of db calls , repetitive calls same condition.there quite lot of condition records in table.we need change make perform better.

2) in previous project had same requirement have configuration table such settings configured,there implemented load configuration table @ start of application , store them in system.setproperty(name,value)..and later use system.getproperty(name) retrieve it.in case settings changed update in system property.this worked charm.

however,in current case(point 1 above) don't think prev way best way because lot of records present in table having lot of columns. can suggest way how achieve such kind of behavior in java? of them can think of is

1) using system.setproperty explained. 2) using caching ehcache - standalone or hibernate(as using hibernate).

any better way store such global settings of application avoid db calls?

best way using ehcache(but have never implemented it). , should not play system property may cause conflict other system properties. how did in case have created bean class having properties yor table column autoid, name, address, mobile.

public map<integer, personbean> gettag() {      map<integer, personbean> map= new hashmap<integer, personbean>();      connection conn =getconnection();      statement st=null;      resultset rs=null;     try     {         string sql = "select autoid,name, address, mobile person";//person table          st =  conn.createstatement();            rs = st.executequery(sql);         while(rs.next()){             int tagid=rs.getint("autoid");             string name=rs.getstring("name");             string address=rs.getstring("address");             string mobile=rs.getstring("mobile");             personbean tagdeatilbean= new personbean(auotoid,name, address, mobile);             map.put(rs.getint("autoid"), tagdeatilbean);         }         return map;     }       catch (sqlexception e) {      }         {      } } 

and bean class

public class personbean  {     private int autoid;     private string name;     private string address;     private string mobile;     public personbean(int autoid, string name, string address, string mobile)     {     this.autoid=autoid;     .....     ....     }      //setter     //getter } 

if web application can load cache map in init method , call value according autuid of row map.


Comments

Popular posts from this blog

c++ - How to add Crypto++ library to Qt project -

jQuery Mobile app not scrolling in Firefox -

How to use vim as editor in Matlab GUI -