Issue #1970 Fixes for Hibernate dataURI and indsertTime Index generation.

Amend: Removed Inheritance strategy from GridRecord.
       Removed dataURI_idx from PluginDataObject.

Change-Id: If04f5388b339ffaafde1693917cf90a8512a1225

Former-commit-id: 51a22d0146 [formerly b0bc5fc2c5] [formerly 51a22d0146 [formerly b0bc5fc2c5] [formerly 89464e243e [formerly 82722bc34cb49b8934063ab6ebdcf66a9bcbe024]]]
Former-commit-id: 89464e243e
Former-commit-id: b9ba987cbe [formerly 96332b9e63]
Former-commit-id: 08715b2985
This commit is contained in:
Brad Gonzales 2013-05-02 11:08:35 -05:00
parent c09c714e58
commit cc691bf629
6 changed files with 35 additions and 16 deletions

View file

@ -50,8 +50,8 @@ import com.raytheon.uf.edex.database.DatabasePluginRegistry;
import com.raytheon.uf.edex.database.DatabaseSessionFactoryBean;
import com.raytheon.uf.edex.database.IDatabasePluginRegistryChanged;
import com.raytheon.uf.edex.database.cluster.ClusterLockUtils;
import com.raytheon.uf.edex.database.cluster.ClusterTask;
import com.raytheon.uf.edex.database.cluster.ClusterLockUtils.LockState;
import com.raytheon.uf.edex.database.cluster.ClusterTask;
import com.raytheon.uf.edex.database.dao.CoreDao;
import com.raytheon.uf.edex.database.dao.DaoConfig;
import com.raytheon.uf.edex.database.plugin.PluginVersion;
@ -67,6 +67,8 @@ import com.raytheon.uf.edex.database.plugin.PluginVersionDao;
* 10/8/2008 1532 bphillip Initial checkin
* 2/9/2009 1990 bphillip Fixed index creation
* 03/20/09 njensen Implemented IPluginRegistryChanged
* Mar 02, 2013 1970 bgonzale Updated createIndexTableNamePattern to match text preceeding
* %TABLE%.
* </pre>
*
* @author bphillip
@ -100,7 +102,7 @@ public class SchemaManager implements IDatabasePluginRegistryChanged {
.compile("^create (?:table |index |sequence )(?:[A-Za-z_0-9]*\\.)?(.+?)(?: .*)?$");
private Pattern createIndexTableNamePattern = Pattern
.compile("^create index %TABLE%.+? on (.+?) .*$");
.compile("^create index \\w*?%TABLE%.+? on (.+?) .*$");
/**
* Gets the singleton instance
@ -294,8 +296,7 @@ public class SchemaManager implements IDatabasePluginRegistryChanged {
runPluginScripts(props);
String database = props.getDatabase();
PluginVersion pv = new PluginVersion(props.getPluginName(),
true,
props.getTableName(), database);
true, props.getTableName(), database);
pvd.saveOrUpdate(pv);
logger.info(pluginName + " plugin initialization complete!");
} else if (initialized == false) {
@ -343,9 +344,6 @@ public class SchemaManager implements IDatabasePluginRegistryChanged {
createSql.add(sql);
}
// only truly want the sql for just this plugin
removeAllDependentCreateSql(props, sessFactory, createSql);
for (int i = 0; i < createSql.size(); i++) {
String sql = createSql.get(i);
if (sql.startsWith("create index")) {
@ -358,6 +356,9 @@ public class SchemaManager implements IDatabasePluginRegistryChanged {
}
createSql.trimToSize();
// only truly want the sql for just this plugin
removeAllDependentCreateSql(props, sessFactory, createSql);
pluginCreateSql.put(fqn, createSql);
}
return createSql;

View file

@ -23,13 +23,13 @@ import java.util.Collection;
import javax.persistence.CascadeType;
import javax.persistence.Embedded;
import javax.persistence.Entity;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.ManyToOne;
import javax.persistence.MappedSuperclass;
import javax.persistence.PrimaryKeyJoinColumn;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.persistence.UniqueConstraint;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
@ -59,15 +59,17 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
* 20080221 862 jkorman Initial Coding.
* 02/06/09 1990 bphillip removed populateDataStore method
* Apr 12, 2013 1857 bgonzale Added SequenceGenerator annotation.
* Mar 02, 2013 1970 bgonzale Removed Table annotation, changed from Entity
* annotation to MappedSuperClass.
*
* </pre>
*
* @author jkorman
* @version 1.0
*/
@Entity
@SequenceGenerator(initialValue = 1, name = PluginDataObject.ID_GEN, sequenceName = "bufrmosseq")
@Table(name = "bufrmos", uniqueConstraints = { @UniqueConstraint(columnNames = { "dataURI" }) })
@MappedSuperclass
@SequenceGenerator(name = PluginDataObject.ID_GEN)
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
@XmlRootElement
@XmlAccessorType(XmlAccessType.NONE)
@DynamicSerialize

View file

@ -21,12 +21,16 @@ package com.raytheon.uf.common.dataplugin.npp.sounding;
import javax.persistence.Column;
import javax.persistence.Embedded;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.MappedSuperclass;
import javax.persistence.SequenceGenerator;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import com.raytheon.uf.common.dataplugin.IDecoderGettable;
import com.raytheon.uf.common.dataplugin.PluginDataObject;
import com.raytheon.uf.common.dataplugin.annotations.DataURI;
import com.raytheon.uf.common.dataplugin.persist.PersistablePluginDataObject;
import com.raytheon.uf.common.pointdata.IPointData;
@ -45,6 +49,8 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
* ------------ ---------- ----------- --------------------------
* Jan 3, 2013 mschenke Initial creation
* Apr 12, 2013 1857 bgonzale Changed to MappedSuperclass.
* Mar 02, 2013 1970 bgonzale Added SequenceGenerator and Inheritance Strategy
* annotations.
*
* </pre>
*
@ -52,6 +58,8 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
* @version 1.0
*/
@MappedSuperclass
@SequenceGenerator(name = PluginDataObject.ID_GEN)
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
@DynamicSerialize
@XmlAccessorType(XmlAccessType.NONE)
public abstract class NPPSoundingRecord extends PersistablePluginDataObject

View file

@ -41,6 +41,7 @@ import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import org.apache.commons.beanutils.PropertyUtils;
import org.hibernate.annotations.Index;
import com.raytheon.uf.common.dataplugin.annotations.DataURI;
import com.raytheon.uf.common.dataplugin.annotations.DataURIUtil;
@ -78,6 +79,7 @@ import com.raytheon.uf.common.util.ConvertUtil;
* Mar 29, 2013 1638 mschenke Added methods for loading from data map and creating data map from
* dataURI fields
* Apr 15, 2013 1868 bsteffen Improved performance of createDataURIMap
* Mar 02, 2013 1970 bgonzale Moved Index annotation from getters to attributes.
* </pre>
*
*/
@ -116,6 +118,7 @@ public abstract class PluginDataObject extends PersistableDataObject implements
/** The timestamp denoting when this record was inserted into the database */
@Column(columnDefinition = "timestamp without time zone")
@Index(name = "%TABLE%_insertTimeIndex")
@XmlAttribute
@DynamicSerializeElement
protected Calendar insertTime;

View file

@ -23,7 +23,10 @@ import java.util.Calendar;
import java.util.Date;
import java.util.TimeZone;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.MappedSuperclass;
import javax.persistence.SequenceGenerator;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
@ -42,6 +45,8 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
* Dec 16, 2008 chammack Initial creation
* Apr 8, 2013 1293 bkowal Removed references to hdffileid.
* Apr 12, 2013 1857 bgonzale Changed to MappedSuperclass.
* Mar 02, 2013 1970 bgonzale Added SequenceGenerator and Inheritance Strategy
* annotations.
*
* </pre>
*
@ -49,6 +54,8 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
* @version 1.0
*/
@MappedSuperclass
@SequenceGenerator(name = PluginDataObject.ID_GEN)
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
@XmlAccessorType(XmlAccessType.NONE)
@DynamicSerialize
public abstract class PersistablePluginDataObject extends PluginDataObject

View file

@ -40,7 +40,6 @@ import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.hibernate.annotations.Index;
import org.hibernate.annotations.Type;
import com.raytheon.uf.common.serialization.ISerializableObject;
@ -61,6 +60,7 @@ import com.raytheon.uf.common.time.util.TimeUtil;
* Jim Ramer Original Code
* Jun 18, 2007 chammack Partial port to Java
* Apr 12, 2013 1857 bgonzale Added Index annotations to getter methods.
* Mar 02, 2013 1970 bgonzale Removed Index annotations.
*
* </pre>
*
@ -344,7 +344,6 @@ public class DataTime implements Comparable<DataTime>, Serializable,
/**
* @return the refTime
*/
@Index(name = "refTimeIndex")
public Date getRefTime() {
return this.refTime;
}
@ -361,7 +360,6 @@ public class DataTime implements Comparable<DataTime>, Serializable,
/**
* @return the fcstTime
*/
@Index(name = "fcstTimeIndex")
public int getFcstTime() {
return fcstTime;
}