Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 336501 - PersistenceOptions.DEFAULT_TEMPORAL_VALUE, "DATE" overrides @Temporal annotation
Summary: PersistenceOptions.DEFAULT_TEMPORAL_VALUE, "DATE" overrides @Temporal annotation
Status: CLOSED WORKSFORME
Alias: None
Product: EMF
Classification: Modeling
Component: Teneo (show other bugs)
Version: unspecified   Edit
Hardware: PC Linux
: P3 minor (vote)
Target Milestone: ---   Edit
Assignee: Martin Taal CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-02-07 08:37 EST by David Wynter CLA
Modified: 2011-12-05 15:09 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description David Wynter CLA 2011-02-07 08:37:23 EST
Build Identifier: Build id: 20100917-0705

This line of code not only makes the default Date but also overrides any annotations for timestamp

            props.setProperty(PersistenceOptions.DEFAULT_TEMPORAL_VALUE, "DATE");

It should be the other way around, where the annotation over-rides the default.

Here is the resultant stack trace

2011-02-0518:01:15.321 GMT+0000 21354 [main] ERROR org.mortbay.log -
failed HibernateSessionRequestFilter
org.hibernate.HibernateException: Wrong column type in
DMANAGER.PUBLIC.cleansingexception for column timereported. Found:
timestamp, expected: date
at org.hibernate.mapping.Table.validateColumns(Table.java:284)
at org.hibernate.cfg.Configuration.validateSchema(Configuration.java:1130)
at
org.hibernate.tool.hbm2ddl.SchemaValidator.validate(SchemaValidator.java:139)

at
org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:359)
at
org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1341)

at
org.eclipse.emf.teneo.hibernate.HbSessionDataStore.buildSessionFactory(HbSessionDataStore.java:218)
 

Reproducible: Always

Steps to Reproduce:
1. Set the above property in your Hibernate utility class
2. Run your utlity class
3.
Comment 1 Martin Taal CLA 2011-02-21 00:50:44 EST
Hi David,
I tried to reproduce this but I could not. Afaics it works fine. I set this property:
		props.setProperty(PersistenceOptions.DEFAULT_TEMPORAL_VALUE, "DATE");


and used the model below. What I can see is that the annotation is correctly copied from the simpletype to the EAttribute. Then in the SingleAttributeAnnotator there is this code:

		if (aAttribute.getTemporal() == null) {
			setTemporal(aAttribute, optionDefaultTemporal);
		}
as the temporal is set (copied from the edatatype), it is not overwritten by the default property. If you have time can you debug in that part of the code?

This is the test model I used:

	<xsd:complexType name="Test">
		<xsd:sequence>
			<xsd:element name="name" type="xsd:string">
				<xsd:annotation>
					<xsd:appinfo source="teneo.jpa">@Id</xsd:appinfo>
				</xsd:annotation>
			</xsd:element>
			<xsd:element name="dateOrTime" type="this:javaDateTime" />
			<xsd:element name="dateOrTimes" type="this:javaDateTime"
				maxOccurs="unbounded" />
		</xsd:sequence>
	</xsd:complexType>

	<xsd:simpleType name="javaDateTime" ecore:instanceClass="java.sql.Timestamp">
		<xsd:annotation>
			<xsd:appinfo source="teneo.jpa">@Temporal(TIMESTAMP)</xsd:appinfo>
		</xsd:annotation>
		<xsd:restriction base="xsd:dateTime">
		</xsd:restriction>
	</xsd:simpleType>