Forums de discussion

ORMException retrieving data from external source

thumbnail
Jorge Rivera, modifié il y a 7 années.

ORMException retrieving data from external source

Junior Member Publications: 26 Date d'inscription: 16/11/11 Publications récentes
Hello

I'm trying to retrieve some records from an external database, I'm using a custom SQL query to get a specific record given a column name, I'm getting the following error:
	
com.liferay.portal.kernel.dao.orm.ORMException: java.lang.IllegalArgumentException: Timestamp format must be yyyy-mm-dd hh:mm:ss[.fffffffff]

This is the custom query:
	
    <sql id="getRecordsByFunnelId">
		
			SELECT 	FunnelID,ProjctType,ContractType,ProjectManager,PreSalesManager,TotalWeightedUserCount,PopStartDate,OriginalContractValue,TotalContractValue,FundingConsumed,ETC_Revenue,CurrentCost,OriginalBudgetDays,ActualConsumedDays,CO_Value,OutcomeMeasurementKPI,OutcomeMeasurementKPI_Metric,OutcomeMeasurementKPI_Objective,OutcomeMeasurementKPI_Description,OutcomeMeasurementMeasurementFormula,OutcomeMeasurementKPITargetDate,OutcomeMeasurementKPIActualDate,OutcomeMeasurementTargetDate,OutcomeMeasurementActualDate,OutcomeMeasurementAchievementTargetDate,OutcomeMeasurementAchievementActualDate,OutcomeMeasurementExecutiveTargetDate,OutcomeMeasurementExecutiveActualDate,timeperiod 
			FROM data_view 
			WHERE FunnelID = ?
		
	</sql>

This is the entity:

	<entity name="DataWarehouse" table="data_view" session-factory="myAppSessionFactory" tx-manager="myAppTransactionManager" local-service="true" cache-enabled="false" human-name="DataWarehouse">
		<column name="FunnelID" type="String" primary="true" />
		<column name="ProjctType" type="String" />
		<column name="ContractType" type="String" />
		<column name="ProjectManager" type="String" />
		<column name="PreSalesManager" type="String" />
		<column name="TotalWeightedUserCount" type="double" />
		<column name="PopStartDate" type="Date" />
		<column name="OriginalContractValue" type="double" />
		<column name="TotalContractValue" type="double" />
		<column name="FundingConsumed" type="double" />
		<column name="ETC_Revenue" type="double" />
		<column name="CurrentCost" type="double" />
		<column name="OriginalBudgetDays" type="double" />
		<column name="ActualConsumedDays" type="double" />
		<column name="CO_Value" type="double" />
		<column name="OutcomeMeasurementKPI" type="String" />
		<column name="OutcomeMeasurementKPI_Metric" type="String" />
		<column name="OutcomeMeasurementKPI_Objective" type="String" />
		<column name="OutcomeMeasurementKPI_Description" type="String" />
		<column name="OutcomeMeasurementMeasurementFormula" type="String" />
		<column name="OutcomeMeasurementKPITargetDate" type="Date" />
		<column name="OutcomeMeasurementKPIActualDate" type="Date" />
		<column name="OutcomeMeasurementTargetDate" type="Date" />
		<column name="OutcomeMeasurementActualDate" type="Date" />
		<column name="OutcomeMeasurementAchievementTargetDate" type="Date" />
		<column name="OutcomeMeasurementAchievementActualDate" type="Date" />
		<column name="OutcomeMeasurementExecutiveTargetDate" type="Date" />
		<column name="OutcomeMeasurementExecutiveActualDate" type="Date" />
		<column name="timeperiod" type="String" />
		
		<finder return-type="Collection" name="Funnel">
			<finder-column name="FunnelID" />
		</finder>
	</entity>

This is the method I set in the finderImpl to get the data:

	public List<datawarehouse> getDataByFunnelID (String funnelId) {
		List<datawarehouse> result = Collections.emptyList();
		
		Session session = null;
		
		try{
			session = openSession();
			
			String sql = CustomSQLUtil.get(FIND_FUNNELID);
			
			SQLQuery q = session.createSQLQuery(sql);
			q.setCacheable(false);
			
			QueryPos qPos = QueryPos.getInstance(q);
			qPos.add(funnelId);
			
			q.addEntity("get_data_by_funnelId", DataWarehouseImpl.class);

			result = (List<datawarehouse>) q.list();
			
		} catch (Exception e) {
			log.error("Error retrieving data by funnel Id: "+e);
		}
		
		return result;
	}
</datawarehouse></datawarehouse></datawarehouse>


I've also tried using the finder I set in the entity but it gives me slightly the same error:
 com.liferay.portal.kernel.exception.SystemException: com.liferay.portal.kernel.dao.orm.ORMException: java.lang.IllegalArgumentException: Timestamp format must be yyyy-mm-dd hh:mm:ss[.fffffffff]


What can I do to fix this?
thumbnail
David H Nebinger, modifié il y a 7 années.

RE: ORMException retrieving data from external source (Réponse)

Liferay Legend Publications: 14919 Date d'inscription: 02/09/06 Publications récentes
What version of Liferay?

Your error is on the timestamp format. Have you checked your DB entity to verify that the listed date columns are formatted correctly, that they are in fact date columns (and not string cols that are being converted)?






Come meet me at the LSNA!
thumbnail
Jorge Rivera, modifié il y a 7 années.

RE: ORMException retrieving data from external source

Junior Member Publications: 26 Date d'inscription: 16/11/11 Publications récentes
Hello David

You were right, the external data source column types were all Strings, changed the service.xml file and the custom query is working now

Thanks a lot