Skip to content

Commit

Permalink
#146 - Hibernate 4.3.5, project buildable, not deployable (missing sp…
Browse files Browse the repository at this point in the history
…ring dependencies)
  • Loading branch information
stebjan committed Feb 8, 2016
1 parent 340e847 commit 0c36113
Show file tree
Hide file tree
Showing 20 changed files with 75 additions and 22 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>3.6.7.Final</version>
<version>4.3.5.Final</version>
<exclusions>
<exclusion>
<artifactId>xml-apis</artifactId>
Expand All @@ -455,7 +455,7 @@
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-tools</artifactId>
<version>3.2.4.GA</version>
<version>4.3.2.Final</version>
</dependency>

<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
package cz.zcu.kiv.eegdatabase.data.dao;

import cz.zcu.kiv.eegdatabase.data.pojo.ScenarioSchemas;

import java.sql.Clob;
import java.util.List;

/**
Expand All @@ -41,4 +43,6 @@ public interface ScenarioSchemasDao extends GenericDao<ScenarioSchemas, Integer>
public int getNextSchemaId();

List<ScenarioSchemas> getListOfScenarioSchemas();

Clob createClob(String content);
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

import cz.zcu.kiv.eegdatabase.data.pojo.ServiceResult;

import java.sql.Blob;
import java.util.List;

/**
Expand All @@ -36,4 +37,6 @@
public interface ServiceResultDao extends GenericDao<ServiceResult, Integer> {

public List<ServiceResult> getResultByPerson(int personId);

Blob createBlob(byte[] content);
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@
package cz.zcu.kiv.eegdatabase.data.dao;

import cz.zcu.kiv.eegdatabase.data.pojo.ScenarioSchemas;
import org.hibernate.Hibernate;

import java.sql.Clob;
import java.util.List;

/**
Expand Down Expand Up @@ -76,4 +78,9 @@ public List<ScenarioSchemas> getListOfScenarioSchemas() {
return list;
}

@Override
public Clob createClob(String content) {
return Hibernate.getLobCreator(this.getSessionFactory().getCurrentSession()).createClob(content);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@
package cz.zcu.kiv.eegdatabase.data.dao;

import cz.zcu.kiv.eegdatabase.data.pojo.ServiceResult;
import org.hibernate.Hibernate;

import java.sql.Blob;
import java.util.List;
import java.util.Map;

Expand All @@ -44,4 +46,9 @@ public List<ServiceResult> getResultByPerson(int personId) {
String hqlQuery = "from ServiceResult s where s.owner.personId = :personId";
return getHibernateTemplate().findByNamedParam(hqlQuery, "personId", personId);
}

@Override
public Blob createBlob(byte[] content) {
return Hibernate.getLobCreator(this.getSessionFactory().getCurrentSession()).createBlob(content);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
import org.apache.commons.logging.LogFactory;
import org.elasticsearch.index.query.IdsQueryBuilder;
import org.hibernate.LazyInitializationException;
import org.hibernate.event.PostLoadEvent;
import org.hibernate.event.PostLoadEventListener;
import org.hibernate.event.spi.PostLoadEvent;
import org.hibernate.event.spi.PostLoadEventListener;
import org.springframework.data.elasticsearch.core.ElasticsearchTemplate;
import org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder;
import org.springframework.data.elasticsearch.core.query.SearchQuery;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ public void setExperiments(Set<Experiment> experiments) {
this.experiments = experiments;
}

@XmlJavaTypeAdapter(BlobSerializer.class)
//@XmlJavaTypeAdapter(BlobSerializer.class)
@Basic(fetch=FetchType.LAZY)
@Lob
@Column(name = "SCENARIO_FILE", nullable = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,8 +253,9 @@ public int addDataFile(DataFileInfo info, DataHandler inputData) throws ClientSe

try {
if (inputData != null) {

file.setFileContent(Hibernate.createBlob(inputData.getInputStream()));

file.setFileContent(Hibernate.getLobCreator(personDao.getSessionFactory().getCurrentSession()).
createBlob(inputData.getInputStream(), info.getFileLength()));
}
} catch (IOException ex) {
log.error(ex.getMessage(), ex);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import java.util.*;

import org.hibernate.Hibernate;
import org.hibernate.Session;

/**
* Web service providing user's data remotely.
Expand Down Expand Up @@ -351,10 +352,12 @@ public int addOrUpdateDataFile(DataFileInfo dataFile, DataHandler inputData) thr
file.setDescription(dataFile.getDescription());
file.setFilename(dataFile.getFileName());
file.setMimetype(dataFile.getMimeType());
Session session = experimentDao.getSessionFactory().getCurrentSession();

try {
if (inputData != null) {
file.setFileContent(Hibernate.createBlob(inputData.getInputStream()));
// file.setFileContent(Hibernate.createBlob(inputData.getInputStream()));
file.setFileContent(Hibernate.getLobCreator(session).createBlob(inputData.getInputStream(), dataFile.getFileLength()));
}
} catch (IOException e) {
log.error(e.getMessage(), e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import java.sql.Blob;
import javax.xml.bind.annotation.adapters.XmlAdapter;
import org.hibernate.Hibernate;
import org.hibernate.Session;

public class BlobSerializer extends XmlAdapter<String, Blob> {

Expand All @@ -13,7 +14,7 @@ public Blob unmarshal(String v) throws Exception {
if (v == null) {
v = "";
}
return Hibernate.createBlob(v.getBytes());
return Hibernate.getLobCreator((Session) null).createBlob(v.getBytes());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public int create(int experimentId, String description, MultipartFile file) thro
datafile.setExperiment(experimentDao.getExperimentForDetail(experimentId));
datafile.setDescription(description);
datafile.setFilename(file.getOriginalFilename().replace(" ", "_"));
datafile.setFileContent(Hibernate.createBlob(file.getBytes()));
datafile.setFileContent(Hibernate.getLobCreator(experimentDao.getSessionFactory().getCurrentSession()).createBlob(file.getBytes()));
datafile.setMimetype(file.getContentType() != null ? file.getContentType().toLowerCase() : "application/octet-stream");

//DB column size restriction
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
*/
package cz.zcu.kiv.eegdatabase.wui.core.scenarios;

import java.sql.Clob;
import java.util.List;

import cz.zcu.kiv.eegdatabase.data.pojo.Person;
Expand Down Expand Up @@ -79,4 +80,6 @@ public interface ScenariosFacade extends GenericFacade<Scenario, Integer> {
void flush();

Scenario getScenarioByTitle(String input);

Clob createClob(String content);
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
*/
package cz.zcu.kiv.eegdatabase.wui.core.scenarios;

import java.sql.Clob;
import java.util.List;

import org.apache.commons.logging.Log;
Expand Down Expand Up @@ -140,6 +141,11 @@ public Scenario getScenarioByTitle(String title) {
return service.getScenarioByTitle(title);
}

@Override
public Clob createClob(String content) {
return service.createClob(content);
}

// @Override
// public Integer create(ScenarioSchemas newInstance) {
// return service.create(newInstance);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
*/
package cz.zcu.kiv.eegdatabase.wui.core.scenarios;

import java.sql.Clob;
import java.util.List;

import cz.zcu.kiv.eegdatabase.data.pojo.Person;
Expand Down Expand Up @@ -79,4 +80,6 @@ public interface ScenariosService extends GenericService<Scenario, Integer> {
List<ScenarioSchemas> getListOfScenarioSchemas();

FileDTO getScenarioFile(int scenarioId);

Clob createClob(String content);
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import java.io.IOException;
import java.io.InputStream;
import java.sql.Blob;
import java.sql.Clob;
import java.sql.SQLException;
import java.util.List;

Expand Down Expand Up @@ -310,4 +311,9 @@ public FileDTO getScenarioFile(int scenarioId) {
}

}

@Override
public Clob createClob(String content) {
return schemaDAO.createClob(content);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import cz.zcu.kiv.eegdatabase.wui.core.file.FileDTO;
import org.springframework.transaction.annotation.Transactional;

import java.sql.Blob;
import java.sql.SQLException;
import java.util.List;

Expand Down Expand Up @@ -65,4 +66,6 @@ public interface SignalProcessingService extends GenericService<ServiceResult, I

@Transactional(readOnly = true)
FileDTO getResultFile(int resultId);

public Blob createBlob(byte[] content);
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.sql.Blob;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -242,6 +243,11 @@ public FileDTO getResultFile(int resultId) {

}

@Override
public Blob createBlob(byte[] content) {
return resultDao.createBlob(content);
}

public ProcessService getEegService() {
return eegService;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,9 @@ public void onSubmit() {
String pojo = schemaGenerator.generatePojo();
String bean = schemaGenerator.generateBean();

scenarioSchema.setSql(Hibernate.createClob(sql));
scenarioSchema.setHbmXml(Hibernate.createClob(hbmXml));
scenarioSchema.setPojo(Hibernate.createClob(pojo));
scenarioSchema.setSql(scenarioFacade.createClob(sql));
scenarioSchema.setHbmXml(scenarioFacade.createClob(hbmXml));
scenarioSchema.setPojo(scenarioFacade.createClob(pojo));
scenarioSchema.setBean(bean);
scenarioSchema.setApproved('n');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public void run() {
System.out.println("start");

String output = new String(service.processService(files, format, methodName, parameters));
result.setContent(Hibernate.createBlob(output.getBytes()));
result.setContent(service.createBlob(output.getBytes()));
result.setStatus("finished");
result.setFilename(methodName + "_result.xml");
service.update(result);
Expand Down
16 changes: 8 additions & 8 deletions src/main/webapp/WEB-INF/persistence.xml
Original file line number Diff line number Diff line change
Expand Up @@ -108,26 +108,26 @@

<bean id="elasticSynchronizationInterceptor" class="cz.zcu.kiv.eegdatabase.data.nosql.ElasticSynchronizationInterceptor"/>

<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>

<property name="entityInterceptor">
<ref bean="elasticSynchronizationInterceptor"/>
</property>

<property name="eventListeners">
<map>
<entry key="post-load"><ref local="postLoadListener" /></entry>
</map>
</property>
<!--<property name="eventListeners">-->
<!--<map>-->
<!--<entry key="post-load"><ref local="postLoadListener" /></entry>-->
<!--</map>-->
<!--</property>-->

<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">${db.dialect}</prop>
<prop key="autocommmit">true</prop>
<prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
<prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.auto}</prop>
<prop key="hibernate.cache.provider_class">${hibernate.cache.provider_class}</prop>
<!--<prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.auto}</prop>-->
<!--<prop key="hibernate.cache.provider_class">${hibernate.cache.provider_class}</prop>-->
</props>
</property>
<property name="packagesToScan" value="cz.zcu.kiv.eegdatabase.data.pojo"/>
Expand Down

0 comments on commit 0c36113

Please sign in to comment.