Commit 2fbb5e19 by Tuomas Riihimäki

Change custom locking policy to generic '@OptimisticLockingLolicy'-annotation

The need for custom platform was removed when we changed the json-datatype to
jsonb, which allows direct comparisons
1 parent f730180e
...@@ -58,51 +58,12 @@ ...@@ -58,51 +58,12 @@
<version>1.2-SNAPSHOT</version> <version>1.2-SNAPSHOT</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.ancoron.postgresql</groupId>
<artifactId>org.ancoron.postgresql.jpa</artifactId>
<version>9.1.901.jdbc4.1-rc9</version>
<exclusions>
<exclusion>
<artifactId>javax.persistence</artifactId>
<groupId>org.eclipse.persistence</groupId>
</exclusion>
<exclusion>
<artifactId>org.eclipse.persistence.osgi</artifactId>
<groupId>org.eclipse.persistence</groupId>
</exclusion>
<exclusion>
<artifactId>org.eclipse.persistence.core</artifactId>
<groupId>org.eclipse.persistence</groupId>
</exclusion>
<exclusion>
<artifactId>org.postgresql</artifactId>
<groupId>org.ancoron.postgresql</groupId>
</exclusion>
<exclusion>
<artifactId>org.postgresql.net</artifactId>
<groupId>org.ancoron.postgresql</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.postgresql</groupId> <groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId> <artifactId>postgresql</artifactId>
<version>9.3-1102-jdbc41</version> <version>42.2.2.jre7</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.ancoron.postgresql</groupId>
<artifactId>org.postgresql.net</artifactId>
<version>9.1.901.jdbc4.1-rc9</version>
<exclusions>
<exclusion>
<artifactId>org.postgresql</artifactId>
<groupId>org.ancoron.postgresql</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId> <groupId>org.eclipse.persistence</groupId>
<artifactId>org.eclipse.persistence.core</artifactId> <artifactId>org.eclipse.persistence.core</artifactId>
<version>2.5.2-RC1</version> <version>2.5.2-RC1</version>
......
/*
* Copyright Codecrew Ry
*
* All rights reserved.
*
* This license applies to any software containing a notice placed by the
* copyright holder. Such software is herein referred to as the Software.
* This license covers modification, distribution and use of the Software.
*
* Any distribution and use in source and binary forms, with or without
* modification is not permitted without explicit written permission from the
* copyright owner.
*
* A non-exclusive royalty-free right is granted to the copyright owner of the
* Software to use, modify and distribute all modifications to the Software in
* future versions of the Software.
*
*/
package fi.codecrew.moya.database.eclipselink;
import java.util.Hashtable;
import org.ancoron.postgresql.jpa.eclipselink.ExtendedPostgreSQLPlatform;
import org.eclipse.persistence.internal.databaseaccess.FieldTypeDefinition;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Smarter defaults. Use TEXT for string columns and understand JSON fields.
* Also inherit ExtendedPostgreSQLPlatform which understand the Inet types.
*
* @author jkj
*
*/
public class MoyaPostgreSQLPlatform extends ExtendedPostgreSQLPlatform {
private static final long serialVersionUID = 6351395815598077327L;
private static final Logger log = LoggerFactory.getLogger(MoyaPostgreSQLPlatform.class);
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
protected Hashtable buildFieldTypes() {
log.info("Customizing SQL Platform field types for Moya");
Hashtable map = super.buildFieldTypes();
map.put(String.class, new FieldTypeDefinition("TEXT", false));
map.put(java.sql.Timestamp.class, new FieldTypeDefinition("TIMESTAMPTZ", false));
map.put(javax.json.JsonObject.class, new FieldTypeDefinition("JSON", false));
return map;
}
}
...@@ -28,8 +28,11 @@ import javax.persistence.Transient; ...@@ -28,8 +28,11 @@ import javax.persistence.Transient;
import fi.codecrew.moya.utilities.jpa.EntityEquals; import fi.codecrew.moya.utilities.jpa.EntityEquals;
import fi.codecrew.moya.utilities.jpa.ModelInterface; import fi.codecrew.moya.utilities.jpa.ModelInterface;
import org.eclipse.persistence.annotations.OptimisticLocking;
import org.eclipse.persistence.annotations.OptimisticLockingType;
@MappedSuperclass @MappedSuperclass
@OptimisticLocking(type= OptimisticLockingType.ALL_COLUMNS)
public class GenericEntity extends EntityEquals implements ModelInterface, EntityMeta { public class GenericEntity extends EntityEquals implements ModelInterface, EntityMeta {
private static final long serialVersionUID = -9041737052951021560L; private static final long serialVersionUID = -9041737052951021560L;
......
...@@ -8,8 +8,7 @@ ...@@ -8,8 +8,7 @@
<property name="eclipselink.cache.size.default" value="16384" /> <property name="eclipselink.cache.size.default" value="16384" />
<property name="eclipselink.logging.logger" value="ServerLogger" /> <property name="eclipselink.logging.logger" value="ServerLogger" />
<property name="eclipselink.jdbc.uppercase-columns" value="false" /> <property name="eclipselink.jdbc.uppercase-columns" value="false" />
<property name="eclipselink.target-database" <property name="eclipselink.target-database" value="PostgreSQL" />
value="fi.codecrew.moya.database.eclipselink.MoyaPostgreSQLPlatform" />
<property name="eclipselink.create-ddl-jdbc-file-name" value="moyaCreateDDL.sql" /> <property name="eclipselink.create-ddl-jdbc-file-name" value="moyaCreateDDL.sql" />
<property name="eclipselink.drop-ddl-jdbc-file-name" value="moyaDropDDL.sql" /> <property name="eclipselink.drop-ddl-jdbc-file-name" value="moyaDropDDL.sql" />
<property name="eclipselink.target-server" value="Glassfish" /> <property name="eclipselink.target-server" value="Glassfish" />
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!