Resolving: java.sql.Timestamp does not have a no-arg default constructor
2012-08-17 15:53
429 查看
Resolving: java.sql.Timestamp does not have a no-arg default constructor
Problem: getting java.sql.Timestamp does not have a no-arg default constructorSolution: Create an XMLAdapter
Example: Annotate the field:
@XmlJavaTypeAdapter( TimestampAdapter.class)
public Timestamp done_date;And you’ll need the actual TimestampAdapter class:
public class TimestampAdapter extends XmlAdapter<Date, Timestamp> {
public Date marshal(Timestamp v) {
return new Date(v.getTime());
}
public Timestamp unmarshal(Date v) {
return new Timestamp(v.getTime());
}
}You can also annotate the package holding the object you are marshaling with the Timestamp attribute. e.g. in com/example/package-info.java have:
@XmlJavaTypeAdapters(
@XmlJavaTypeAdapter(value=TimestampAdapter.class,type=Timestamp.class))
package com.example;Note that annotations do not flow ‘down’ to the sub packages. e.g. no use putting the package-info.java in the ‘com’ package.
Better solution: someone at Sun/Oracle annotate the actual Timestamp class please?
相关文章推荐
- how to solve "java.sql.Timestamp does not have a no-arg default constructor" ? .
- how to solve "java.sql.Timestamp does not have a no-arg default constructor" ?
- java.sql.timestamp does not have a no-arg default constructor
- java.sql.SQLException: Userdoes not have access to metadata required to determine stored procedurepa
- “java.sql.SQLException: Value '0000-00-00' can not be represented as java.sql.Timestamp”
- 提示Value '0000-00-00 00:00:00' can not be represented as java.sql.Timestamp;
- Sql 2005 Database diagram support objects cannot be installed because this database does not have a valid owner
- MySQL关于Value '0000-00-00 00:00:00' can not be represented as java.sql.Timestamp
- Value '0000-00-00 00:00:00' can not be represented as java.sql.Timestamp
- SQLException:value '0000-00-00' can not be represended as java.sql.TimeStamp
- java.sql.SQLException: Field 'id' doesn't have a default value
- spring No default constructor found; nested exception is java.lang.NoSuchMethodException: com.slj.mo
- java.sql.SQLException: Field 'id' doesn't have a default value解决方法
- MySQL关于Value '0000-00-00 00:00:00' can not be represented as java.sql.Timestamp
- Caused by: java.sql.SQLException: Field 'id' doesn't have a default value .
- java 正则表达式报错:Look-behind group does not have an obvious maximum length near index
- mysql解决Value ‘0000-00-00 00:00:00’ can not be represented as java.sql.Timestamp
- 错误:java.sql.SQLSyntaxErrorException: ORA-02289: sequence does not exist
- Gson Exception: No-args constructor for class XXX does not exit.
- java.sql.SQLException: Value '[B@8ea6b9' can not be represented as java.sql.Timestamp