我在TIMESTAMPTZ的eclipselink中遇到问题。表中有一列,其中包含时间戳和时区。当我运行程序时,出现异常。
我已经尝试了stackOverflow上的所有问题,甚至在以下链接上也遇到了类似的问题。
https://www.eclipse.org/forums/index.php/t/443917/
Query q = em.createNativeQuery("SELECT * FROM MY_Schema.MyTable MT WHERE MT.START_DT = (SELECT MAX(START_DT) FROM MY_Schema.MyTable)",MyTable.class);
@Entity
@Table(name = "MyTable", schema = "MY_Schema")
public class MyTable implements Serializable {
@EmbeddedId
private MyTableId id;
@Embeddable
public class MyTableId implements Serializable {
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "END_DT")
private Calendar endTime;
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "START_DT")
private Calendar startTime;
错误消息:
5943 [Default Executor-thread-32] ERROR com....MyClass -
javax.persistence.PersistenceException: Exception [EclipseLink-3002]
(Eclipse Persistence Services - 2.6.8.WAS-v20181218-0accd7f):
org.eclipse.persistence.exceptions.ConversionException Exception
Description: The object [oracle.sql.TIMESTAMPTZ@d1f0d927], of class
[class oracle.sql.TIMESTAMPTZ], from mapping
[org.eclipse.persistence.mappings.DirectToFieldMapping[startTime--Y_Schema.MyTable.START_DT]]
with descriptor [RelationalDescriptor(com.....MyTableId -->
[DatabaseTable(MY_Schema.MyTable)])], could not be converted to [class
java.util.Date]. at
org.eclipse.persistence.internal.jpa.QueryImpl.getSingleResult(QueryImpl.java:551)