mirror of https://github.com/apache/openjpa.git
OPENJPA-303 committing on behalf of Albert
git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@561405 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
7ca46cf69d
commit
a1d28857fa
|
@ -991,8 +991,10 @@ public class AnnotationPersistenceMappingParser
|
|||
if (!cols.isEmpty() && cols.size() != 1)
|
||||
throw new MetaDataException(_loc.get("num-cols-mismatch", fm,
|
||||
String.valueOf(cols.size()), "1"));
|
||||
if (cols.isEmpty())
|
||||
if (cols.isEmpty()) {
|
||||
cols = Arrays.asList(new Column[]{ new Column() });
|
||||
fm.getValueInfo().setColumns(cols);
|
||||
}
|
||||
|
||||
Column col = (Column) cols.get(0);
|
||||
switch (anno.value()) {
|
||||
|
|
|
@ -0,0 +1,61 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.apache.openjpa.jdbc.meta;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
|
||||
import org.apache.openjpa.persistence.simple.TemporalFieldTypes;
|
||||
import org.apache.openjpa.persistence.test.SQLListenerTestCase;
|
||||
|
||||
public class TestMappingToolTemporal extends SQLListenerTestCase {
|
||||
|
||||
public void setUp() {
|
||||
setUp(CLEAR_TABLES, TemporalFieldTypes.class);
|
||||
}
|
||||
|
||||
public void testMappingToolTemporal() throws IOException, SQLException {
|
||||
|
||||
EntityManager em = emf.createEntityManager();
|
||||
em.getTransaction().begin();
|
||||
em.persist(new TemporalFieldTypes());
|
||||
em.getTransaction().commit();
|
||||
em.close();
|
||||
|
||||
assertSQL("CREATE TABLE TemporalFieldTypes "
|
||||
+ "(.*dateDefaultField TIMESTAMP.*)");
|
||||
assertSQL("CREATE TABLE TemporalFieldTypes "
|
||||
+ "(.*dateDateField DATE.*)");
|
||||
assertSQL("CREATE TABLE TemporalFieldTypes "
|
||||
+ "(.*dateTimeField TIME.*)");
|
||||
assertSQL("CREATE TABLE TemporalFieldTypes "
|
||||
+ "(.*dateTimestampField TIMESTAMP.*)");
|
||||
|
||||
assertSQL("CREATE TABLE TemporalFieldTypes "
|
||||
+ "(.*calendarDefaultField TIMESTAMP.*)");
|
||||
assertSQL("CREATE TABLE TemporalFieldTypes "
|
||||
+ "(.*calendarDateField DATE.*)");
|
||||
assertSQL("CREATE TABLE TemporalFieldTypes "
|
||||
+ "(.*calendarTimeField TIME.*)");
|
||||
assertSQL("CREATE TABLE TemporalFieldTypes "
|
||||
+ "(.*calendarTimestampField TIMESTAMP.*)");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,117 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.apache.openjpa.persistence.simple;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Temporal;
|
||||
import javax.persistence.TemporalType;
|
||||
|
||||
@Entity
|
||||
public class TemporalFieldTypes {
|
||||
|
||||
// Date mapping - Default to TIMESTAMP
|
||||
private Date dateDefaultField;
|
||||
|
||||
@Temporal(TemporalType.DATE)
|
||||
private Date dateDateField;
|
||||
|
||||
@Temporal(TemporalType.TIME)
|
||||
private Date dateTimeField;
|
||||
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
private Date dateTimestampField;
|
||||
|
||||
// Calendar mapping - Default to TIMESTAMP
|
||||
private Calendar calendarDefaultField;
|
||||
|
||||
@Temporal(TemporalType.DATE)
|
||||
private Calendar calendarDateField;
|
||||
|
||||
@Temporal(TemporalType.TIME)
|
||||
private Calendar calendarTimeField;
|
||||
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
private Calendar calendarTimestampField;
|
||||
|
||||
public void setDateDefaultField(Date date) {
|
||||
this.dateDefaultField = date;
|
||||
}
|
||||
|
||||
public Date getDateDefaultField() {
|
||||
return this.dateDefaultField;
|
||||
}
|
||||
|
||||
public void setDateDateField(Date date) {
|
||||
this.dateDateField = date;
|
||||
}
|
||||
|
||||
public Date getDateDateField() {
|
||||
return this.dateDateField;
|
||||
}
|
||||
|
||||
public void setDateTimeField(Date date) {
|
||||
this.dateTimeField = date;
|
||||
}
|
||||
|
||||
public Date getDateTimeField() {
|
||||
return this.dateTimeField;
|
||||
}
|
||||
|
||||
public void setDateTimeStampField(Date date) {
|
||||
this.dateTimestampField = date;
|
||||
}
|
||||
|
||||
public Date getDateTimeStampField() {
|
||||
return this.dateTimestampField;
|
||||
}
|
||||
|
||||
public void setCalendarDefaultField(Calendar calendar) {
|
||||
this.calendarDefaultField = calendar;
|
||||
}
|
||||
|
||||
public Calendar getCalendarDefaultField() {
|
||||
return this.calendarDefaultField;
|
||||
}
|
||||
|
||||
public void setCalendarDateField(Calendar calendar) {
|
||||
this.calendarDateField = calendar;
|
||||
}
|
||||
|
||||
public Calendar getCalendarDateField() {
|
||||
return this.calendarDateField;
|
||||
}
|
||||
|
||||
public void setCalendarTimeField(Calendar calendar) {
|
||||
this.calendarTimeField = calendar;
|
||||
}
|
||||
|
||||
public Calendar getCalendarTimeField() {
|
||||
return this.calendarTimeField;
|
||||
}
|
||||
|
||||
public void setCalendarTimeStampField(Calendar calendar) {
|
||||
this.calendarTimestampField = calendar;
|
||||
}
|
||||
|
||||
public Calendar getCalendarTimeStampField() {
|
||||
return this.calendarTimestampField;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue