Skip to main content

Posts

Showing posts from July, 2012

HIbernate @version for existing data, cannot be null

Hibernate have option to check concurrent modification of a same data. Which will be easy when we add a version column in the table and hibernate entity. If existing row has version as NULL then hibernate will throw the NullPointerException while updating the existing data. To avoid this exception   @version column  should be NOT NULL and should have a default value. if it number 1.

remove(unset) property in a property file using ANT PropertyFile task

Using PropertyFile task we can edit the property file during ANT build. Edit property value are very easy and can find here details. http://ant.apache.org/manual/Tasks/propertyfile.html but delete a property or comment a property is the tricky one. If we are using latest ant version (1.8.1 or later), we can delete a property like below. <propertyfile file="my.properties" comment="My properties">   < entry  key="propertykey" operation="del"/> < /propertyfile> but the older version that is before 1.8.1 don't have operation called " del ", if we run the command in lower version ant, we will get a error says undefined operation "del".      there is workaround instead deleting a property we can comment that property using ant's replace command. < replace file="sample.properties">                      < replacefilter token="propertykey" value="#propert