@Version()
private Long version;
try {
spaceShipManager.saveSpaceShip(ship);
} catch (HibernateOptimisticLockingFailureException e) {
return mapping.findForward("error");
}
try {
spaceShipManager.saveSpaceShip(ship);
} catch (HibernateOptimisticLockingFailureException e) {
return mapping.findForward("error");
}
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>Instrument domain classes</id>
<configuration>
<tasks>
<taskdef name="instrument"
classname="org.hibernate.tool.instrument.cglib.InstrumentTask">
<classpath>
<path refid="maven.dependency.classpath"/>
<path refid="maven.plugin.classpath"/>
</classpath>
</taskdef>
<instrument verbose="true">
<fileset dir="${project.build.outputDirectory}">
<include name="**/model/*.class"/>
</fileset>
</instrument>
</tasks>
</configuration>
<phase>process-classes</phase>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate</artifactId>
<version>3.2.6.ga</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<!-- hibernate ddl generation -->
<groupId>org.codehaus.mojo</groupId>
<artifactId>hibernate3-maven-plugin</artifactId>
<version>2.0-alpha-2</version>
<configuration>
<components>
<component>
<name>hbm2ddl</name>
<outputDirectory>.</outputDirectory>
</component>
</components>
<componentProperties>
<configurationfile>src/main/db/hibernate.cfg.xml</configurationfile>
<drop>false</drop>
<create>true</create>
<export>false</export>
<jdk5>true</jdk5>
<format>true</format>
</componentProperties>
</configuration>
<executions>
<execution>
<id>export-mysql</id>
<phase>process-classes</phase>
<goals>
<goal>hbm2ddl</goal>
</goals>
<configuration>
<componentProperties>
<propertyfile>src/main/db/hibernate-mysql.properties</propertyfile>
<outputfilename>target/mysql-ddl.sql</outputfilename>
</componentProperties>
</configuration>
</execution>
</executions>
</plugin>
<?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>
<!--Annotated classes-->
<mapping class="com.etymgiko.lyricscollection.model.Artist" />
<mapping class="com.etymgiko.lyricscollection.model.Song" />
</session-factory>
</hibernate-configuration>
# This properties file defines the dialect for the MYSQL database
hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect
import java.util.Arrays;
public class SystemProperties {
public static void main(String [] args) {
String [] keys = System.getProperties().keySet()
.toArray(new String [] {});
Arrays.sort(keys);
for (String key: keys) {
String value = System.getProperty(key);
System.out.println(key + ": " + value);
}
}
}