Posts

Struts 2 Troubleshooting

Image
  How to add session in struts2 action class: You can access the session object using a jsp scriplet and set your required variables there. <% request.getSession().setAttribute("your_variable",obj) %> From the Action class , you can get access to session either by implementing the ServletRequestAware Interface within your action class or by implementing the SessionAware interface. request.getSession().getAttribute("var"); ref:   http://struts.1045723.n5.nabble.com/How-to-set-a-variable-in-session-in-the-JSP-td3499780.html OR add an attribute "private Map session;" in Action class. create getters and setters. use below code to put and get values from sesiion. session = ActionContext.getContext().getSession();  session.put("logged_in", "no"); boolean loggedIn = (Boolean) session.get("logged-in"); session.remove("selectedMatch");

Hibernate-Inheritance Mapping with XML

Image
hibernate.cfg.xml <?xml version='1.0' encoding='UTF-8'?> <!DOCTYPE hibernate-configuration PUBLIC           "-//Hibernate/Hibernate Configuration DTD 3.0//EN"           "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"> <hibernate-configuration> <session-factory>     <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property> <property name="hibernate.connection.url">jdbc:mysql://localhost:3306/Test</property> <property name="hibernate.connection.username">root</property> <property name="hibernate.connection.password">minu</property> <property name="dialect">org.hibernate.dialect.MySQLDialect</property> <property name="show_sql">true</property> <property name="hbm2ddl.auto">update</property> <mapping resourc

Hibernate -Collection Mapping with annotations

Image
hibernate.cfg.xml <?xml version='1.0' encoding='UTF-8'?> <!DOCTYPE hibernate-configuration PUBLIC           "-//Hibernate/Hibernate Configuration DTD 3.0//EN"           "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"> <hibernate-configuration> <session-factory>     <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property> <property name="hibernate.connection.url">jdbc:mysql://localhost:3306/Test</property> <property name="hibernate.connection.username">root</property> <property name="hibernate.connection.password">minu</property> <property name="dialect">org.hibernate.dialect.MySQLDialect</property> <property name="show_sql">true</property> <property name="hbm2ddl.auto">update</property> <mapping class=&

Hibernate Collection Mapping example

Image
hibernate.cfg.xml <?xml version='1.0' encoding='UTF-8'?> <!DOCTYPE hibernate-configuration PUBLIC           "-//Hibernate/Hibernate Configuration DTD 3.0//EN"           "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"> <hibernate-configuration> <session-factory>     <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property> <property name="hibernate.connection.url">jdbc:mysql://localhost:3306/Test</property> <property name="hibernate.connection.username">root</property> <property name="hibernate.connection.password">minu</property> <property name="dialect">org.hibernate.dialect.MySQLDialect</property> <property name="show_sql">true</property> <property name="hbm2ddl.auto">update</property> <mapping resourc