Month: February 2015

Creating shortcut for an application and adding to launch panel – Ubuntu

Install Gnome Panel

sudo apt-get install gnome-panel

Create new desktop shortcut

gnome-desktop-item-edit ~/Desktop/ –create-new

Custom application laucher will be poped up now. Add your application name, Command and Icon.

A desktop shortcut will be created.

Drag the shortcut to Launcher then it will be locked with Launcher

 

Generic way of mapping hbm file

We no need to map individual hbm files simply add the below highlighted property which solves the problem

<bean id=”factory” class=”org.springframework.orm.hibernate3.LocalSessionFactoryBean” destroy-method=”destroy”>
<property name=”mappingLocations” value=”classpath:**/*.hbm.xml” />
<property name=”hibernateProperties”>
<props>
<prop key=”hibernate.dialect”>org.hibernate.dialect.MySQLDialect</prop>
<prop key=”connection.provider_class”>org.hibernate.connection.C3P0ConnectionProvider</prop>
<prop key=”hibernate.c3p0.max_size”>5</prop>
<prop key=”hibernate.c3p0.min_size”>1</prop>
<prop key=”hibernate.c3p0.idle_test_period”>60</prop>
<prop key=”hibernate.c3p0.timeout”>10</prop>
<prop key=”hibernate.connection.autoReconnect”>true</prop>

</props>
</property>
<property name=”dataSource”>
<ref bean=”dataSource” />
</property>
</bean>

Invalid date in MYSQL causing problem in java application

Exception:
Caused by: java.sql.SQLException: Cannot convert value ‘0000-00-00 00:00:00’ from column 42 to TIMESTAMP.
Solution:
In hibernate data source mapping property please add the highlighted property
jdbc:mysql://yourserver:3306/yourdatabase?zeroDateTimeBehavior=convertToNull
 By default these invalid date will be converted into null values when it comes to Java object.
 Alternate options:

  • exception (the default), which throws an SQLException with an SQLState of S1009.
  • convertToNull, which returns NULL instead of the date.
  • round, which rounds the date to the nearest closest value which is 0001-01-01.