Get JPA working with single table

This commit is contained in:
jamesagnew 2014-05-21 08:04:00 -04:00
parent ee0a16990b
commit 75205c5d75
31 changed files with 224 additions and 419 deletions

View File

@ -175,59 +175,6 @@
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<groupId>de.juplo</groupId>
<artifactId>hibernate4-maven-plugin</artifactId>
<version>1.0.1</version>
<configuration>
<force>true</force>
<target>SCRIPT</target>
<skip>false</skip>
</configuration>
<executions>
<execution>
<id>o10g</id>
<goals>
<goal>export</goal>
</goals>
<configuration>
<hibernateDialect>org.hibernate.dialect.Oracle10gDialect</hibernateDialect>
<outputFile>${project.build.directory}/schema_oracle_10g.sql</outputFile>
</configuration>
</execution>
<execution>
<id>derby</id>
<goals>
<goal>export</goal>
</goals>
<configuration>
<hibernateDialect>org.hibernate.dialect.DerbyTenSevenDialect</hibernateDialect>
<outputFile>${project.build.directory}/schema_derby.sql</outputFile>
</configuration>
</execution>
<execution>
<id>hsql</id>
<goals>
<goal>export</goal>
</goals>
<configuration>
<hibernateDialect>org.hibernate.dialect.HSQLDialect</hibernateDialect>
<outputFile>${project.build.directory}/schema_hsql.sql</outputFile>
</configuration>
</execution>
<execution>
<id>mysql5</id>
<goals>
<goal>export</goal>
</goals>
<configuration>
<hibernateDialect>org.hibernate.dialect.MySQL5Dialect</hibernateDialect>
<outputFile>${project.build.directory}/schema_mysql_5.sql</outputFile>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

View File

@ -1,6 +1,6 @@
package ca.uhn.fhir.jpa.dao;
import static org.apache.commons.lang3.StringUtils.isBlank;
import static org.apache.commons.lang3.StringUtils.*;
import java.text.Normalizer;
import java.util.ArrayList;
@ -41,7 +41,7 @@ import ca.uhn.fhir.context.RuntimeChildResourceDefinition;
import ca.uhn.fhir.context.RuntimeResourceDefinition;
import ca.uhn.fhir.context.RuntimeSearchParam;
import ca.uhn.fhir.jpa.entity.BaseHasResource;
import ca.uhn.fhir.jpa.entity.BaseResourceTable;
import ca.uhn.fhir.jpa.entity.ResourceTable;
import ca.uhn.fhir.jpa.entity.BaseTag;
import ca.uhn.fhir.jpa.entity.ResourceHistoryTable;
import ca.uhn.fhir.jpa.entity.ResourceIndexedSearchParamDate;
@ -75,12 +75,11 @@ import ca.uhn.fhir.rest.param.QualifiedDateParam;
import ca.uhn.fhir.rest.param.ReferenceParam;
import ca.uhn.fhir.rest.param.StringParam;
import ca.uhn.fhir.rest.server.EncodingEnum;
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException;
import ca.uhn.fhir.util.FhirTerser;
public class FhirResourceDao<T extends IResource, X extends BaseResourceTable<T>> implements IFhirResourceDao<T> {
public class FhirResourceDao<T extends IResource> implements IFhirResourceDao<T> {
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(FhirResourceDao.class);
private FhirContext myCtx;
@ -96,16 +95,15 @@ public class FhirResourceDao<T extends IResource, X extends BaseResourceTable<T>
private Class<T> myResourceType;
private Map<Class<? extends IResource>, IFhirResourceDao<?>> myResourceTypeToDao;
private Class<X> myTableType;
@Transactional(propagation = Propagation.REQUIRED, readOnly = true)
@Override
public MethodOutcome create(T theResource) {
final X entity = toEntity(theResource);
final ResourceTable entity = toEntity(theResource);
entity.setPublished(new Date());
entity.setUpdated(entity.getPublished());
entity.setResourceType(toResourceName(theResource));
final List<ResourceIndexedSearchParamString> stringParams = extractSearchParamStrings(entity, theResource);
final List<ResourceIndexedSearchParamToken> tokenParams = extractSearchParamTokens(entity, theResource);
@ -118,9 +116,9 @@ public class FhirResourceDao<T extends IResource, X extends BaseResourceTable<T>
TransactionTemplate template = new TransactionTemplate(myPlatformTransactionManager);
template.setPropagationBehavior(TransactionTemplate.PROPAGATION_REQUIRES_NEW);
template.setReadOnly(false);
template.execute(new TransactionCallback<X>() {
template.execute(new TransactionCallback<ResourceTable>() {
@Override
public X doInTransaction(TransactionStatus theStatus) {
public ResourceTable doInTransaction(TransactionStatus theStatus) {
myEntityManager.persist(entity);
for (ResourceIndexedSearchParamString next : stringParams) {
myEntityManager.persist(next);
@ -145,14 +143,15 @@ public class FhirResourceDao<T extends IResource, X extends BaseResourceTable<T>
return outcome;
}
private String toResourceName(T theResource) {
return myCtx.getResourceDefinition(theResource).getName();
}
public Class<T> getResourceType() {
return myResourceType;
}
@Override
public Class<X> getTableType() {
return myTableType;
}
@Transactional(propagation = Propagation.REQUIRED)
@Override
@ -186,7 +185,6 @@ public class FhirResourceDao<T extends IResource, X extends BaseResourceTable<T>
@PostConstruct
public void postConstruct() throws Exception {
myResourceType = myTableType.newInstance().getResourceType();
myCtx = new FhirContext(myResourceType);
myResourceName = myCtx.getResourceDefinition(myResourceType).getName();
}
@ -194,7 +192,7 @@ public class FhirResourceDao<T extends IResource, X extends BaseResourceTable<T>
@Transactional(propagation = Propagation.REQUIRED)
@Override
public T read(IdDt theId) {
X entity = readEntity(theId);
ResourceTable entity = readEntity(theId);
T retVal = toResource(entity);
return retVal;
@ -226,15 +224,16 @@ public class FhirResourceDao<T extends IResource, X extends BaseResourceTable<T>
// Execute the query and make sure we return distinct results
{
CriteriaBuilder builder = myEntityManager.getCriteriaBuilder();
CriteriaQuery<X> cq = builder.createQuery(myTableType);
Root<X> from = cq.from(myTableType);
CriteriaQuery<ResourceTable> cq = builder.createQuery(ResourceTable.class);
Root<ResourceTable> from = cq.from(ResourceTable.class);
cq.where(builder.equal(from.get("myResourceType"), myCtx.getResourceDefinition(myResourceType).getName()));
if (!theParams.isEmpty()) {
cq.where(from.get("myId").in(pids));
}
TypedQuery<X> q = myEntityManager.createQuery(cq);
TypedQuery<ResourceTable> q = myEntityManager.createQuery(cq);
List<T> retVal = new ArrayList<>();
for (X next : q.getResultList()) {
for (ResourceTable next : q.getResultList()) {
T resource = toResource(next);
retVal.add(resource);
}
@ -321,9 +320,10 @@ public class FhirResourceDao<T extends IResource, X extends BaseResourceTable<T>
return pids;
}
@SuppressWarnings("unchecked")
@Required
public void setTableType(Class<X> theTableType) {
myTableType = theTableType;
public void setResourceType(Class<? extends IResource> theTableType) {
myResourceType = (Class<T>) theTableType;
}
@Transactional(propagation = Propagation.SUPPORTS)
@ -331,11 +331,11 @@ public class FhirResourceDao<T extends IResource, X extends BaseResourceTable<T>
public MethodOutcome update(final T theResource, final IdDt theId) {
TransactionTemplate template = new TransactionTemplate(myPlatformTransactionManager);
X savedEntity = template.execute(new TransactionCallback<X>() {
ResourceTable savedEntity = template.execute(new TransactionCallback<ResourceTable>() {
@Override
public X doInTransaction(TransactionStatus theStatus) {
public ResourceTable doInTransaction(TransactionStatus theStatus) {
final X entity = readEntity(theId);
final ResourceTable entity = readEntity(theId);
entity.setUpdated(entity.getPublished());
final ResourceHistoryTable historyEntry = entity.toHistory(myCtx);
@ -733,7 +733,7 @@ public class FhirResourceDao<T extends IResource, X extends BaseResourceTable<T>
return new HashSet<Long>(q.getResultList());
}
private List<ResourceLink> extractResourceLinks(X theEntity, T theResource) {
private List<ResourceLink> extractResourceLinks(ResourceTable theEntity, T theResource) {
ArrayList<ResourceLink> retVal = new ArrayList<ResourceLink>();
RuntimeResourceDefinition def = myCtx.getResourceDefinition(theResource);
@ -770,7 +770,10 @@ public class FhirResourceDao<T extends IResource, X extends BaseResourceTable<T>
}
Map<Class<? extends IResource>, IFhirResourceDao<?>> resourceTypeToDao = getResourceTypeToDao();
Class<? extends BaseResourceTable<?>> tableType = resourceTypeToDao.get(type).getTableType();
IFhirResourceDao<?> dao = resourceTypeToDao.get(type);
if (dao == null) {
throw new InvalidRequestException("This server is not able to handle resources of type: " + nextValue.getResourceType());
}
Long valueOf;
try {
valueOf = Long.valueOf(id);
@ -778,7 +781,7 @@ public class FhirResourceDao<T extends IResource, X extends BaseResourceTable<T>
String resName = myCtx.getResourceDefinition(type).getName();
throw new InvalidRequestException("Resource ID " + resName + "/" + id + " is invalid (must be numeric), specified in path: " + nextPath);
}
BaseResourceTable<?> target = myEntityManager.find(tableType, valueOf);
ResourceTable target = myEntityManager.find(ResourceTable.class, valueOf);
if (target == null) {
String resName = myCtx.getResourceDefinition(type).getName();
throw new InvalidRequestException("Resource " + resName + "/" + id + " not found, specified in path: " + nextPath);
@ -802,7 +805,7 @@ public class FhirResourceDao<T extends IResource, X extends BaseResourceTable<T>
return retVal;
}
private List<ResourceIndexedSearchParamDate> extractSearchParamDates(X theEntity, T theResource) {
private List<ResourceIndexedSearchParamDate> extractSearchParamDates(ResourceTable theEntity, T theResource) {
ArrayList<ResourceIndexedSearchParamDate> retVal = new ArrayList<ResourceIndexedSearchParamDate>();
RuntimeResourceDefinition def = myCtx.getResourceDefinition(theResource);
@ -840,7 +843,7 @@ public class FhirResourceDao<T extends IResource, X extends BaseResourceTable<T>
}
}
if (nextEntity != null) {
nextEntity.setResource(theEntity, def.getName());
nextEntity.setResource(theEntity);
retVal.add(nextEntity);
}
}
@ -851,7 +854,7 @@ public class FhirResourceDao<T extends IResource, X extends BaseResourceTable<T>
return retVal;
}
private ArrayList<ResourceIndexedSearchParamNumber> extractSearchParamNumber(X theEntity, T theResource) {
private ArrayList<ResourceIndexedSearchParamNumber> extractSearchParamNumber(ResourceTable theEntity, T theResource) {
ArrayList<ResourceIndexedSearchParamNumber> retVal = new ArrayList<ResourceIndexedSearchParamNumber>();
RuntimeResourceDefinition def = myCtx.getResourceDefinition(theResource);
@ -877,7 +880,7 @@ public class FhirResourceDao<T extends IResource, X extends BaseResourceTable<T>
if (nextObject instanceof QuantityDt) {
QuantityDt nextValue = (QuantityDt) nextObject;
ResourceIndexedSearchParamNumber nextEntity = new ResourceIndexedSearchParamNumber(resourceName, nextValue.getValue().getValue(), nextValue.getSystem().getValueAsString(), nextValue.getUnits().getValue());
nextEntity.setResource(theEntity, def.getName());
nextEntity.setResource(theEntity);
retVal.add(nextEntity);
} else {
if (!multiType) {
@ -894,7 +897,7 @@ public class FhirResourceDao<T extends IResource, X extends BaseResourceTable<T>
return retVal;
}
private List<ResourceIndexedSearchParamString> extractSearchParamStrings(X theEntity, T theResource) {
private List<ResourceIndexedSearchParamString> extractSearchParamStrings(ResourceTable theEntity, T theResource) {
ArrayList<ResourceIndexedSearchParamString> retVal = new ArrayList<ResourceIndexedSearchParamString>();
RuntimeResourceDefinition def = myCtx.getResourceDefinition(theResource);
@ -924,7 +927,7 @@ public class FhirResourceDao<T extends IResource, X extends BaseResourceTable<T>
if (nextObject instanceof IPrimitiveDatatype<?>) {
IPrimitiveDatatype<?> nextValue = (IPrimitiveDatatype<?>) nextObject;
ResourceIndexedSearchParamString nextEntity = new ResourceIndexedSearchParamString(resourceName, normalizeString(nextValue.getValueAsString()), nextValue.getValueAsString());
nextEntity.setResource(theEntity, def.getName());
nextEntity.setResource(theEntity);
retVal.add(nextEntity);
} else {
if (nextObject instanceof HumanNameDt) {
@ -937,7 +940,7 @@ public class FhirResourceDao<T extends IResource, X extends BaseResourceTable<T>
continue;
}
ResourceIndexedSearchParamString nextEntity = new ResourceIndexedSearchParamString(resourceName, normalizeString(nextName.getValueAsString()), nextName.getValueAsString());
nextEntity.setResource(theEntity, def.getName());
nextEntity.setResource(theEntity);
retVal.add(nextEntity);
}
} else if (nextObject instanceof AddressDt) {
@ -953,14 +956,14 @@ public class FhirResourceDao<T extends IResource, X extends BaseResourceTable<T>
continue;
}
ResourceIndexedSearchParamString nextEntity = new ResourceIndexedSearchParamString(resourceName, normalizeString(nextName.getValueAsString()), nextName.getValueAsString());
nextEntity.setResource(theEntity, def.getName());
nextEntity.setResource(theEntity);
retVal.add(nextEntity);
}
} else if (nextObject instanceof ContactDt) {
ContactDt nextContact = (ContactDt) nextObject;
if (nextContact.getValue().isEmpty() == false) {
ResourceIndexedSearchParamString nextEntity = new ResourceIndexedSearchParamString(resourceName, normalizeString(nextContact.getValue().getValueAsString()), nextContact.getValue().getValueAsString());
nextEntity.setResource(theEntity, def.getName());
nextEntity.setResource(theEntity);
retVal.add(nextEntity);
}
} else {
@ -977,7 +980,7 @@ public class FhirResourceDao<T extends IResource, X extends BaseResourceTable<T>
return retVal;
}
private List<ResourceIndexedSearchParamToken> extractSearchParamTokens(X theEntity, T theResource) {
private List<ResourceIndexedSearchParamToken> extractSearchParamTokens(ResourceTable theEntity, T theResource) {
ArrayList<ResourceIndexedSearchParamToken> retVal = new ArrayList<ResourceIndexedSearchParamToken>();
RuntimeResourceDefinition def = myCtx.getResourceDefinition(theResource);
@ -1019,7 +1022,7 @@ public class FhirResourceDao<T extends IResource, X extends BaseResourceTable<T>
continue;
}
nextEntity = new ResourceIndexedSearchParamToken(nextSpDef.getName(), nextCoding.getSystem().getValueAsString(), nextCoding.getCode().getValue());
nextEntity.setResource(theEntity, def.getName());
nextEntity.setResource(theEntity);
retVal.add(nextEntity);
}
nextEntity = null;
@ -1031,7 +1034,7 @@ public class FhirResourceDao<T extends IResource, X extends BaseResourceTable<T>
}
}
if (nextEntity != null) {
nextEntity.setResource(theEntity, def.getName());
nextEntity.setResource(theEntity);
retVal.add(nextEntity);
}
}
@ -1067,43 +1070,38 @@ public class FhirResourceDao<T extends IResource, X extends BaseResourceTable<T>
return new String(out).toUpperCase();
}
private void populateResourceIntoEntity(T theResource, X retVal) {
retVal.setResource(myCtx.newJsonParser().encodeResourceToString(theResource));
retVal.setEncoding(EncodingEnum.JSON);
private void populateResourceIntoEntity(T theResource, ResourceTable theEntity) {
theEntity.setResource(myCtx.newJsonParser().encodeResourceToString(theResource));
theEntity.setEncoding(EncodingEnum.JSON);
TagList tagList = (TagList) theResource.getResourceMetadata().get(ResourceMetadataKeyEnum.TAG_LIST);
if (tagList != null) {
for (Tag next : tagList) {
retVal.addTag(next.getTerm(), next.getLabel(), next.getScheme());
theEntity.addTag(next.getTerm(), next.getLabel(), next.getScheme());
}
}
}
private X readEntity(IdDt theId) {
X entity = (X) myEntityManager.find(myTableType, theId.asLong());
private ResourceTable readEntity(IdDt theId) {
ResourceTable entity = myEntityManager.find(ResourceTable.class, theId.asLong());
if (entity == null) {
throw new ResourceNotFoundException(theId);
}
return entity;
}
private X toEntity(T theResource) {
X retVal;
try {
retVal = myTableType.newInstance();
} catch (InstantiationException | IllegalAccessException e) {
throw new InternalErrorException(e);
}
private ResourceTable toEntity(T theResource) {
ResourceTable retVal = new ResourceTable();
populateResourceIntoEntity(theResource, retVal);
return retVal;
}
private MethodOutcome toMethodOutcome(final X entity) {
private MethodOutcome toMethodOutcome(final ResourceTable entity) {
MethodOutcome outcome = new MethodOutcome();
outcome.setId(entity.getId());
outcome.setId(new IdDt(entity.getId()));
outcome.setVersionId(entity.getVersion());
return outcome;
}
@ -1139,7 +1137,7 @@ public class FhirResourceDao<T extends IResource, X extends BaseResourceTable<T>
String resourceText = theEntity.getResource();
IParser parser = theEntity.getEncoding().newParser(myCtx);
T retVal = parser.parseResource(myResourceType, resourceText);
retVal.setId(theEntity.getId());
retVal.setId(theEntity.getIdDt());
retVal.getResourceMetadata().put(ResourceMetadataKeyEnum.VERSION_ID, theEntity.getVersion());
retVal.getResourceMetadata().put(ResourceMetadataKeyEnum.PUBLISHED, theEntity.getPublished());
retVal.getResourceMetadata().put(ResourceMetadataKeyEnum.UPDATED, theEntity.getUpdated());

View File

@ -4,7 +4,7 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import ca.uhn.fhir.jpa.entity.BaseResourceTable;
import ca.uhn.fhir.jpa.entity.ResourceTable;
import ca.uhn.fhir.model.api.IQueryParameterType;
import ca.uhn.fhir.model.api.IResource;
import ca.uhn.fhir.model.primitive.IdDt;
@ -35,8 +35,6 @@ public interface IFhirResourceDao<T extends IResource> {
Class<T> getResourceType();
Class<? extends BaseResourceTable<T>> getTableType();
Set<Long> searchForIds(String theParameterName, IQueryParameterType theValue);
Set<Long> searchForIds(Map<String, IQueryParameterType> theParams);

View File

@ -41,7 +41,7 @@ public abstract class BaseHasResource {
public abstract Collection<? extends BaseTag> getTags();
public abstract IdDt getId();
public abstract IdDt getIdDt();
public InstantDt getPublished() {
return new InstantDt(myPublished);

View File

@ -6,6 +6,8 @@ import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.MappedSuperclass;
@MappedSuperclass
@ -15,15 +17,22 @@ public abstract class BaseResourceIndexedSearchParam implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "RES_ID")
@Column(name = "SP_ID")
private Long myId;
@Column(name="SP_NAME", length=100)
@Column(name = "SP_NAME", length = 100, nullable=false)
private String myName;
@Column(name = "RES_TYPE",length=100,nullable=false)
@ManyToOne(optional = false)
@JoinColumn(name = "RES_ID", referencedColumnName="RES_ID")
private ResourceTable myResource;
@Column(name = "RES_TYPE", nullable=false)
private String myResourceType;
@Column(name = "RES_ID", insertable = false, updatable = false)
private Long myResourcePid;
public String getName() {
return myName;
}
@ -32,23 +41,13 @@ public abstract class BaseResourceIndexedSearchParam implements Serializable {
myName = theName;
}
public abstract BaseResourceTable<?> getResource();
protected abstract void setResource(BaseResourceTable<?> theResource);
public void setResource(BaseResourceTable<?> theResource, String theResourceType) {
setResource(theResource);
setResourceType(theResourceType);
public ResourceTable getResource() {
return myResource;
}
public String getResourceType() {
return myResourceType;
public void setResource(ResourceTable theResource) {
myResource = theResource;
myResourceType = theResource.getResourceType();
}
public void setResourceType(String theResourceType) {
myResourceType = theResourceType;
}
}

View File

@ -31,7 +31,7 @@ public class ResourceHistoryTable extends BaseHasResource implements Serializabl
private Collection<ResourceHistoryTag> myTags;
@Override
public IdDt getId() {
public IdDt getIdDt() {
return new IdDt(myPk.getId());
}

View File

@ -13,7 +13,7 @@ public class ResourceHistoryTablePk implements Serializable {
@Column(name="PID")
private Long myId;
@Column(name="RES_TYPE", length=100, nullable=false)
@Column(name="RES_TYPE", length=30, nullable=false)
private String myResourceType;
@Column(name="VERSION")

View File

@ -26,22 +26,13 @@ public class ResourceIndexedSearchParamDate extends BaseResourceIndexedSearchPar
@Temporal(TemporalType.TIMESTAMP)
public Date myValueLow;
@ManyToOne(optional = false)
@JoinColumn(name = "RESOURCE_PID", nullable = false, foreignKey=@ForeignKey(name="FK_ISD_RESOURCE"))
private BaseResourceTable<?> myResource;
@Column(name = "RESOURCE_PID", insertable = false, updatable = false)
private Long myResourcePid;
public ResourceIndexedSearchParamDate(String theName, Date theLow, Date theHigh) {
setName(theName);
setValueLow(theLow);
setValueHigh(theHigh);
}
public BaseResourceTable<?> getResource() {
return myResource;
}
public Date getValueHigh() {
return myValueHigh;
@ -59,8 +50,6 @@ public class ResourceIndexedSearchParamDate extends BaseResourceIndexedSearchPar
myValueLow = theValueLow;
}
protected void setResource(BaseResourceTable<?> theResource) {
myResource = theResource;
}
}

View File

@ -4,10 +4,7 @@ import java.math.BigDecimal;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.ForeignKey;
import javax.persistence.Index;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
@Entity
@ -25,13 +22,6 @@ public class ResourceIndexedSearchParamNumber extends BaseResourceIndexedSearchP
@Column(name = "SP_VALUE", nullable = true)
public BigDecimal myValue;
@ManyToOne(optional = false)
@JoinColumn(name = "RESOURCE_PID", nullable = false, foreignKey=@ForeignKey(name="FK_ISN_RESOURCE"))
private BaseResourceTable<?> myResource;
@Column(name = "RESOURCE_PID", insertable = false, updatable = false)
private Long myResourcePid;
public ResourceIndexedSearchParamNumber(String theParamName, BigDecimal theValue, String theSystem, String theUnits) {
setName(theParamName);
setSystem(theSystem);
@ -39,10 +29,6 @@ public class ResourceIndexedSearchParamNumber extends BaseResourceIndexedSearchP
setUnits(theUnits);
}
public BaseResourceTable<?> getResource() {
return myResource;
}
public String getSystem() {
return mySystem;
}
@ -55,9 +41,6 @@ public class ResourceIndexedSearchParamNumber extends BaseResourceIndexedSearchP
return myValue;
}
protected void setResource(BaseResourceTable<?> theResource) {
myResource = theResource;
}
public void setSystem(String theSystem) {
mySystem = theSystem;

View File

@ -2,11 +2,7 @@ package ca.uhn.fhir.jpa.entity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.ForeignKey;
import javax.persistence.Index;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
@Entity
@ -15,13 +11,6 @@ public class ResourceIndexedSearchParamString extends BaseResourceIndexedSearchP
private static final long serialVersionUID = 1L;
@ManyToOne(optional = false, cascade = {}, fetch = FetchType.LAZY)
@JoinColumn(name = "RESOURCE_PID", nullable = false, foreignKey=@ForeignKey(name="FK_ISS_RESOURCE"))
private BaseResourceTable<?> myResource;
@Column(name = "RESOURCE_PID", insertable=false, updatable=false)
private Long myResourcePid;
@Column(name = "SP_VALUE_NORMALIZED", length = 100, nullable = true)
public String myValueNormalized;
@ -37,15 +26,6 @@ public class ResourceIndexedSearchParamString extends BaseResourceIndexedSearchP
setValueExact(theValueExact);
}
public BaseResourceTable<?> getResource() {
return myResource;
}
protected void setResource(BaseResourceTable<?> theResource) {
myResource = theResource;
}
public String getValueNormalized() {
return myValueNormalized;
}

View File

@ -2,29 +2,19 @@ package ca.uhn.fhir.jpa.entity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.ForeignKey;
import javax.persistence.Index;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
@Entity
@Table(name = "SPIDX_TOKEN", indexes= {@Index(name="IDX_SP_STRING", columnList="SP_SYSTEM,SP_VALUE")})
@Table(name = "SPIDX_TOKEN", indexes = { @Index(name = "IDX_SP_STRING", columnList = "SP_SYSTEM,SP_VALUE") })
public class ResourceIndexedSearchParamToken extends BaseResourceIndexedSearchParam {
private static final long serialVersionUID = 1L;
@ManyToOne(optional = false)
@JoinColumn(name = "RESOURCE_PID", nullable = false, foreignKey=@ForeignKey(name="FK_IST_RESOURCE"))
private BaseResourceTable<?> myResource;
@Column(name = "RESOURCE_PID", insertable=false, updatable=false)
private Long myResourcePid;
@Column(name = "SP_VALUE", nullable = true, length=100)
@Column(name = "SP_VALUE", nullable = true, length = 100)
public String myValue;
@Column(name = "SP_SYSTEM", nullable = true, length=100)
@Column(name = "SP_SYSTEM", nullable = true, length = 100)
public String mySystem;
public String getSystem() {
@ -37,25 +27,17 @@ public class ResourceIndexedSearchParamToken extends BaseResourceIndexedSearchPa
public ResourceIndexedSearchParamToken() {
}
public ResourceIndexedSearchParamToken(String theName, String theSystem, String theValue) {
setName(theName);
setSystem(theSystem);
setValue(theValue);
}
public BaseResourceTable<?> getResource() {
return myResource;
}
public String getValue() {
return myValue;
}
protected void setResource(BaseResourceTable<?> theResource) {
myResource = theResource;
}
public void setValue(String theValue) {
myValue = theValue;
}

View File

@ -4,7 +4,6 @@ import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.ForeignKey;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
@ -28,17 +27,17 @@ public class ResourceLink implements Serializable {
private String mySourcePath;
@ManyToOne(optional = false)
@JoinColumn(name = "SRC_RESOURCE_PID", nullable = false, foreignKey = @ForeignKey(name = "FK_RES_LINK_SRC_RES"))
private BaseResourceTable<?> mySourceResource;
@JoinColumn(name = "SRC_RESOURCE_ID", referencedColumnName="RES_ID")
private ResourceTable mySourceResource;
@Column(name = "SRC_RESOURCE_PID", insertable = false, updatable = false)
@Column(name = "SRC_RESOURCE_ID", insertable = false, updatable = false)
private Long mySourceResourcePid;
@ManyToOne(optional = false)
@JoinColumn(name = "TARGET_RESOURCE_PID", nullable = false, foreignKey = @ForeignKey(name = "FK_RES_LINK_TARGET_RES"))
private BaseResourceTable<?> myTargetResource;
@JoinColumn(name = "TARGET_RESOURCE_ID", referencedColumnName="RES_ID")
private ResourceTable myTargetResource;
@Column(name = "TARGET_RESOURCE_PID", insertable = false, updatable = false)
@Column(name = "TARGET_RESOURCE_ID", insertable = false, updatable = false)
private Long myTargetResourcePid;
public ResourceLink() {
@ -50,14 +49,14 @@ public class ResourceLink implements Serializable {
StringBuilder b = new StringBuilder();
b.append("ResourceLink[");
b.append("path=").append(mySourcePath);
b.append(", src=").append(mySourceResource.getIdAsLong());
b.append(", target=").append(myTargetResource.getIdAsLong());
b.append(", src=").append(mySourceResource.getId());
b.append(", target=").append(myTargetResource.getId());
b.append("]");
return b.toString();
}
public ResourceLink(String theSourcePath, BaseResourceTable<?> theSourceResource, BaseResourceTable<?> theTargetResource) {
public ResourceLink(String theSourcePath, ResourceTable theSourceResource, ResourceTable theTargetResource) {
super();
mySourcePath = theSourcePath;
mySourceResource = theSourceResource;
@ -68,7 +67,7 @@ public class ResourceLink implements Serializable {
return mySourcePath;
}
public BaseResourceTable<?> getSourceResource() {
public ResourceTable getSourceResource() {
return mySourceResource;
}
@ -76,7 +75,7 @@ public class ResourceLink implements Serializable {
return mySourceResourcePid;
}
public BaseResourceTable<?> getTargetResource() {
public ResourceTable getTargetResource() {
return myTargetResource;
}
@ -88,7 +87,7 @@ public class ResourceLink implements Serializable {
mySourcePath = theSourcePath;
}
public void setSourceResource(BaseResourceTable<?> theSourceResource) {
public void setSourceResource(ResourceTable theSourceResource) {
mySourceResource = theSourceResource;
}
@ -96,7 +95,7 @@ public class ResourceLink implements Serializable {
mySourceResourcePid = theSourceResourcePid;
}
public void setTargetResource(BaseResourceTable<?> theTargetResource) {
public void setTargetResource(ResourceTable theTargetResource) {
Validate.notNull(theTargetResource);
myTargetResource = theTargetResource;
}

View File

@ -1,12 +1,11 @@
package ca.uhn.fhir.jpa.entity;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.DiscriminatorColumn;
import javax.persistence.DiscriminatorType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
@ -19,14 +18,13 @@ import javax.persistence.Table;
import javax.persistence.Version;
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.model.api.IResource;
import ca.uhn.fhir.model.primitive.IdDt;
@Entity
@Table(name = "BASE_RES", uniqueConstraints = {})
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name = "SVCVER_TYPE", length = 20, discriminatorType = DiscriminatorType.STRING)
public abstract class BaseResourceTable<T extends IResource> extends BaseHasResource {
@Table(name = "RESOURCE", uniqueConstraints = {})
@Inheritance(strategy = InheritanceType.JOINED)
public class ResourceTable extends BaseHasResource implements Serializable {
private static final long serialVersionUID = 1L;
@Column(name = "SP_HAS_LINKS")
private boolean myHasLinks;
@ -66,6 +64,9 @@ public abstract class BaseResourceTable<T extends IResource> extends BaseHasReso
@OneToMany(mappedBy = "mySourceResource", cascade = {}, fetch = FetchType.LAZY, orphanRemoval = false)
private Collection<ResourceLink> myResourceLinks;
@Column(name = "RES_TYPE", length = 30)
private String myResourceType;
@OneToMany(mappedBy = "myResource", cascade = CascadeType.ALL, fetch = FetchType.EAGER, orphanRemoval = true)
private Collection<ResourceTag> myTags;
@ -82,11 +83,11 @@ public abstract class BaseResourceTable<T extends IResource> extends BaseHasReso
getTags().add(new ResourceTag(this, theTerm, theLabel, theScheme));
}
public IdDt getId() {
public IdDt getIdDt() {
return new IdDt(myId);
}
public Long getIdAsLong() {
public Long getId() {
return myId;
}
@ -125,7 +126,9 @@ public abstract class BaseResourceTable<T extends IResource> extends BaseHasReso
return myResourceLinks;
}
public abstract Class<T> getResourceType();
public String getResourceType() {
return myResourceType;
}
public Collection<ResourceTag> getTags() {
if (myTags == null) {
@ -162,8 +165,8 @@ public abstract class BaseResourceTable<T extends IResource> extends BaseHasReso
myHasLinks = theHasLinks;
}
public void setId(IdDt theId) {
myId = theId.asLong();
public void setId(Long theId) {
myId = theId;
}
public void setParamsDate(Collection<ResourceIndexedSearchParamDate> theParamsDate) {
@ -194,6 +197,10 @@ public abstract class BaseResourceTable<T extends IResource> extends BaseHasReso
myParamsTokenPopulated = theParamsTokenPopulated;
}
public void setResourceType(String theResourceType) {
myResourceType = theResourceType;
}
public void setVersion(IdDt theVersion) {
myVersion = theVersion.asLong();
}
@ -203,7 +210,7 @@ public abstract class BaseResourceTable<T extends IResource> extends BaseHasReso
ResourceHistoryTablePk pk = new ResourceHistoryTablePk();
pk.setId(myId);
pk.setResourceType(theCtx.getResourceDefinition(getResourceType()).getName());
pk.setResourceType(myResourceType);
pk.setVersion(myVersion);
retVal.setPk(pk);

View File

@ -1,7 +1,6 @@
package ca.uhn.fhir.jpa.entity;
import javax.persistence.Entity;
import javax.persistence.ForeignKey;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
@ -20,24 +19,24 @@ public class ResourceTag extends BaseTag {
private Long myId;
@ManyToOne(cascade= {})
@JoinColumn(name = "RESOURCE_PID", nullable=false, foreignKey=@ForeignKey(name="FK_RESTAG_RESOURCE"))
private BaseResourceTable<?> myResource;
@JoinColumn(name = "RES_ID", referencedColumnName="RES_ID")
private ResourceTable myResource;
public ResourceTag() {
}
public ResourceTag(BaseResourceTable<?> theResource, String theTerm, String theLabel, String theScheme) {
public ResourceTag(ResourceTable theResource, String theTerm, String theLabel, String theScheme) {
myResource = theResource;
setTerm(theTerm);
setLabel(theLabel);
setScheme(theScheme);
}
public BaseResourceTable<?> getResource() {
public ResourceTable getResource() {
return myResource;
}
public void setResource(BaseResourceTable<?> theResource) {
public void setResource(ResourceTable theResource) {
myResource = theResource;
}

View File

@ -22,6 +22,12 @@ public class CustomNamingStrategy extends ImprovedNamingStrategy {
}
@Override
public String foreignKeyColumnName(String thePropertyName, String thePropertyEntityName, String thePropertyTableName, String theReferencedColumnName) {
String foreignKeyColumnName = super.foreignKeyColumnName(thePropertyName, thePropertyEntityName, thePropertyTableName, theReferencedColumnName);
return foreignKeyColumnName;
}
@Override
public String logicalCollectionTableName(final String tableName,
final String ownerEntityTable, final String associatedEntityTable,
final String propertyName) {

View File

@ -1,18 +0,0 @@
package ca.uhn.fhir.jpa.testentity;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import ca.uhn.fhir.jpa.entity.BaseResourceTable;
import ca.uhn.fhir.model.dstu.resource.Device;
@Entity
@DiscriminatorValue("DEVICE")
public class DeviceResourceTable extends BaseResourceTable<Device> {
@Override
public Class<Device> getResourceType() {
return Device.class;
}
}

View File

@ -1,18 +0,0 @@
package ca.uhn.fhir.jpa.testentity;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import ca.uhn.fhir.jpa.entity.BaseResourceTable;
import ca.uhn.fhir.model.dstu.resource.DiagnosticReport;
@Entity
@DiscriminatorValue("DIAGNOSTICREPORT")
public class DiagnosticReportResourceTable extends BaseResourceTable<DiagnosticReport> {
@Override
public Class<DiagnosticReport> getResourceType() {
return DiagnosticReport.class;
}
}

View File

@ -1,18 +0,0 @@
package ca.uhn.fhir.jpa.testentity;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import ca.uhn.fhir.jpa.entity.BaseResourceTable;
import ca.uhn.fhir.model.dstu.resource.Location;
@Entity
@DiscriminatorValue("LOCATION")
public class LocationResourceTable extends BaseResourceTable<Location> {
@Override
public Class<Location> getResourceType() {
return Location.class;
}
}

View File

@ -1,18 +0,0 @@
package ca.uhn.fhir.jpa.testentity;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import ca.uhn.fhir.jpa.entity.BaseResourceTable;
import ca.uhn.fhir.model.dstu.resource.Observation;
@Entity
@DiscriminatorValue("OBSERVATION")
public class ObservationResourceTable extends BaseResourceTable<Observation> {
@Override
public Class<Observation> getResourceType() {
return Observation.class;
}
}

View File

@ -1,18 +0,0 @@
package ca.uhn.fhir.jpa.testentity;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import ca.uhn.fhir.jpa.entity.BaseResourceTable;
import ca.uhn.fhir.model.dstu.resource.Organization;
@Entity
@DiscriminatorValue("ORGANIZATION")
public class OrganizationResourceTable extends BaseResourceTable<Organization> {
@Override
public Class<Organization> getResourceType() {
return Organization.class;
}
}

View File

@ -1,18 +0,0 @@
package ca.uhn.fhir.jpa.testentity;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import ca.uhn.fhir.jpa.entity.BaseResourceTable;
import ca.uhn.fhir.model.dstu.resource.Patient;
@Entity
@DiscriminatorValue("PATIENT")
public class PatientResourceTable extends BaseResourceTable<Patient> {
@Override
public Class<Patient> getResourceType() {
return Patient.class;
}
}

View File

@ -1,18 +0,0 @@
package ca.uhn.fhir.jpa.testentity;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import ca.uhn.fhir.jpa.entity.BaseResourceTable;
import ca.uhn.fhir.model.dstu.resource.Questionnaire;
@Entity
@DiscriminatorValue("QUESTIONNAIRE")
public class QuestionnaireResourceTable extends BaseResourceTable<Questionnaire> {
@Override
public Class<Questionnaire> getResourceType() {
return Questionnaire.class;
}
}

View File

@ -8,15 +8,7 @@
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<!-- <class>ca.uhn.fhir.jpa.entity.PatientResourceTable</class> -->
<class>ca.uhn.fhir.jpa.testentity.DeviceResourceTable</class>
<class>ca.uhn.fhir.jpa.testentity.DiagnosticReportResourceTable</class>
<class>ca.uhn.fhir.jpa.testentity.LocationResourceTable</class>
<class>ca.uhn.fhir.jpa.testentity.ObservationResourceTable</class>
<class>ca.uhn.fhir.jpa.testentity.OrganizationResourceTable</class>
<class>ca.uhn.fhir.jpa.testentity.PatientResourceTable</class>
<class>ca.uhn.fhir.jpa.testentity.QuestionnaireResourceTable</class>
<class>ca.uhn.fhir.jpa.testentity.QuestionnaireResourceTable</class>
<class>ca.uhn.fhir.jpa.entity.ResourceTable</class>
<class>ca.uhn.fhir.jpa.entity.ResourceHistoryTable</class>
<class>ca.uhn.fhir.jpa.entity.ResourceHistoryTag</class>
<class>ca.uhn.fhir.jpa.entity.ResourceIndexedSearchParamDate</class>

View File

@ -13,23 +13,26 @@
<context:annotation-config />
<context:mbean-server />
<bean id="myPatientDao" class="ca.uhn.fhir.jpa.dao.FhirResourceDao">
<property name="tableType" value="ca.uhn.fhir.jpa.testentity.PatientResourceTable"/>
</bean>
<bean id="myObservationDao" class="ca.uhn.fhir.jpa.dao.FhirResourceDao">
<property name="tableType" value="ca.uhn.fhir.jpa.testentity.ObservationResourceTable"/>
</bean>
<bean id="myDiagnosticReportDao" class="ca.uhn.fhir.jpa.dao.FhirResourceDao">
<property name="tableType" value="ca.uhn.fhir.jpa.testentity.DiagnosticReportResourceTable"/>
<property name="resourceType" value="ca.uhn.fhir.model.dstu.resource.DiagnosticReport"/>
</bean>
<bean id="myDeviceDao" class="ca.uhn.fhir.jpa.dao.FhirResourceDao">
<property name="tableType" value="ca.uhn.fhir.jpa.testentity.DeviceResourceTable"/>
<property name="resourceType" value="ca.uhn.fhir.model.dstu.resource.Device"/>
</bean>
<bean id="myLocationDao" class="ca.uhn.fhir.jpa.dao.FhirResourceDao">
<property name="tableType" value="ca.uhn.fhir.jpa.testentity.LocationResourceTable"/>
<bean id="myPatientDao" class="ca.uhn.fhir.jpa.dao.FhirResourceDao">
<property name="resourceType" value="ca.uhn.fhir.model.dstu.resource.Patient"/>
</bean>
<bean id="myObservationDao" class="ca.uhn.fhir.jpa.dao.FhirResourceDao">
<property name="resourceType" value="ca.uhn.fhir.model.dstu.resource.Observation"/>
</bean>
<bean id="myOrganizationDao" class="ca.uhn.fhir.jpa.dao.FhirResourceDao">
<property name="tableType" value="ca.uhn.fhir.jpa.testentity.OrganizationResourceTable"/>
<property name="resourceType" value="ca.uhn.fhir.model.dstu.resource.Organization"/>
</bean>
<bean id="myLocationDao" class="ca.uhn.fhir.jpa.dao.FhirResourceDao">
<property name="resourceType" value="ca.uhn.fhir.model.dstu.resource.Location"/>
</bean>
<bean id="myQuestionnaireDao" class="ca.uhn.fhir.jpa.dao.FhirResourceDao">
<property name="resourceType" value="ca.uhn.fhir.model.dstu.resource.Questionnaire"/>
</bean>
<bean id="myPersistenceDataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource" lazy-init="true">

View File

@ -2,8 +2,6 @@
<classpath>
<classpathentry excluding="**/*.java" kind="src" output="target/test-classes" path="src/test/resources"/>
<classpathentry kind="src" path="target/generated-sources/tinder"/>
<classpathentry including="**/*.java" kind="src" path="src/main/java"/>
<classpathentry excluding="**/*.java" kind="src" path="src/main/resources"/>
<classpathentry kind="src" path="src/test/java"/>
<classpathentry kind="var" path="M2_REPO/javax/activation/activation/1.1/activation-1.1.jar" sourcepath="M2_REPO/javax/activation/activation/1.1/activation-1.1-sources.jar"/>
<classpathentry kind="var" path="M2_REPO/javax/json/javax.json-api/1.0/javax.json-api-1.0.jar" sourcepath="M2_REPO/javax/json/javax.json-api/1.0/javax.json-api-1.0-sources.jar"/>

View File

@ -20,6 +20,11 @@
<artifactId>hapi-fhir-jpaserver-base</artifactId>
<version>0.4-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.thymeleaf</groupId>
<artifactId>thymeleaf</artifactId>
<version>2.1.2.RELEASE</version>
</dependency>
<dependency>
<groupId>junit</groupId>
@ -80,7 +85,7 @@
</plugins>
</pluginManagement>
<plugins>
<plugin>
<plugin>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-tinder-plugin</artifactId>
<version>0.4-SNAPSHOT</version>
@ -107,6 +112,63 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>de.juplo</groupId>
<artifactId>hibernate4-maven-plugin</artifactId>
<version>1.0.2</version>
<configuration>
<force>true</force>
<target>SCRIPT</target>
<skip>false</skip>
<scanTestClasses>true</scanTestClasses>
</configuration>
<executions>
<execution>
<id>o10g</id>
<goals>
<goal>export</goal>
</goals>
<phase>test</phase>
<configuration>
<hibernateDialect>org.hibernate.dialect.Oracle10gDialect</hibernateDialect>
<outputFile>${project.build.directory}/schema_oracle_10g.sql</outputFile>
</configuration>
</execution>
<execution>
<id>derby</id>
<goals>
<goal>export</goal>
</goals>
<phase>test</phase>
<configuration>
<hibernateDialect>org.hibernate.dialect.DerbyTenSevenDialect</hibernateDialect>
<outputFile>${project.build.directory}/schema_derby.sql</outputFile>
</configuration>
</execution>
<execution>
<id>hsql</id>
<goals>
<goal>export</goal>
</goals>
<phase>test</phase>
<configuration>
<hibernateDialect>org.hibernate.dialect.HSQLDialect</hibernateDialect>
<outputFile>${project.build.directory}/schema_hsql.sql</outputFile>
</configuration>
</execution>
<execution>
<id>mysql5</id>
<goals>
<goal>export</goal>
</goals>
<phase>test</phase>
<configuration>
<hibernateDialect>org.hibernate.dialect.MySQL5Dialect</hibernateDialect>
<outputFile>${project.build.directory}/schema_mysql_5.sql</outputFile>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>

View File

@ -14,19 +14,19 @@
<context:mbean-server />
<bean id="myPatientDao" class="ca.uhn.fhir.jpa.dao.FhirResourceDao">
<property name="tableType" value="ca.uhn.test.jpasrv.PatientResourceTable"/>
<property name="resourceType" value="ca.uhn.fhir.model.dstu.resource.Patient"/>
</bean>
<bean id="myObservationDao" class="ca.uhn.fhir.jpa.dao.FhirResourceDao">
<property name="tableType" value="ca.uhn.test.jpasrv.ObservationResourceTable"/>
<property name="resourceType" value="ca.uhn.fhir.model.dstu.resource.Observation"/>
</bean>
<bean id="myOrganizationDao" class="ca.uhn.fhir.jpa.dao.FhirResourceDao">
<property name="tableType" value="ca.uhn.test.jpasrv.OrganizationResourceTable"/>
<property name="resourceType" value="ca.uhn.fhir.model.dstu.resource.Organization"/>
</bean>
<bean id="myLocationDao" class="ca.uhn.fhir.jpa.dao.FhirResourceDao">
<property name="tableType" value="ca.uhn.test.jpasrv.LocationResourceTable"/>
<property name="resourceType" value="ca.uhn.fhir.model.dstu.resource.Location"/>
</bean>
<bean id="myQuestionnaireDao" class="ca.uhn.fhir.jpa.dao.FhirResourceDao">
<property name="tableType" value="ca.uhn.test.jpasrv.QuestionnaireResourceTable"/>
<property name="resourceType" value="ca.uhn.fhir.model.dstu.resource.Questionnaire"/>
</bean>
<bean id="myPersistenceDataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource" lazy-init="true">

View File

@ -7,10 +7,6 @@
<persistence-unit name="FHIR_UT" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<class>ca.uhn.test.jpasrv.PatientResourceTable</class>
<class>ca.uhn.test.jpasrv.LocationResourceTable</class>
<class>ca.uhn.test.jpasrv.ObservationResourceTable</class>
<class>ca.uhn.test.jpasrv.OrganizationResourceTable</class>
<class>ca.uhn.test.jpasrv.QuestionnaireResourceTable</class>
<class>ca.uhn.fhir.jpa.entity.ResourceHistoryTable</class>
<class>ca.uhn.fhir.jpa.entity.ResourceHistoryTag</class>
<class>ca.uhn.fhir.jpa.entity.ResourceIndexedSearchParamDate</class>
@ -18,6 +14,7 @@
<class>ca.uhn.fhir.jpa.entity.ResourceIndexedSearchParamString</class>
<class>ca.uhn.fhir.jpa.entity.ResourceIndexedSearchParamToken</class>
<class>ca.uhn.fhir.jpa.entity.ResourceLink</class>
<class>ca.uhn.fhir.jpa.entity.ResourceTable</class>
<class>ca.uhn.fhir.jpa.entity.ResourceTag</class>
<exclude-unlisted-classes>true</exclude-unlisted-classes>

View File

@ -69,9 +69,9 @@ public class TinderJpaRestServerMojo extends AbstractMojo {
gen.setTemplate("/vm/jpa_resource_provider.vm");
gen.writeAll(directoryBase, packageBase);
gen.setFilenameSuffix("ResourceTable");
gen.setTemplate("/vm/jpa_resource_table.vm");
gen.writeAll(directoryBase, packageBase);
// gen.setFilenameSuffix("ResourceTable");
// gen.setTemplate("/vm/jpa_resource_table.vm");
// gen.writeAll(directoryBase, packageBase);
} catch (Exception e) {
throw new MojoFailureException("Failed to generate server",e);

View File

@ -1,19 +0,0 @@
package ${packageBase};
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import ca.uhn.fhir.jpa.entity.BaseResourceTable;
import ca.uhn.fhir.model.dstu.resource.*;
@Entity
@DiscriminatorValue("${className}")
public class ${className}ResourceTable extends BaseResourceTable<${className}> {
@Override
public Class<${className}> getResourceType() {
return ${className}.class;
}
}

View File

@ -33,6 +33,17 @@
<scope>provided</scope>
</dependency>
<!--
If you are using HAPI narrative generation, you will need to include Thymeleaf
as well. Otherwise the following can be omitted.
-->
<dependency>
<groupId>org.thymeleaf</groupId>
<artifactId>thymeleaf</artifactId>
<version>2.1.2.RELEASE</version>
<optional>true</optional>
</dependency>
</dependencies>
<build>