Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/jpa/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jpa 如何设置@DateTimeFormat(pattern=";yyyy/MM";之类的模式_Jpa_Nhibernate Mapping_Spring Annotations_Hibernate Entitymanager - Fatal编程技术网

Jpa 如何设置@DateTimeFormat(pattern=";yyyy/MM";之类的模式

Jpa 如何设置@DateTimeFormat(pattern=";yyyy/MM";之类的模式,jpa,nhibernate-mapping,spring-annotations,hibernate-entitymanager,Jpa,Nhibernate Mapping,Spring Annotations,Hibernate Entitymanager,我对hibernate pojo注释有疑问。数据库中有一列是varchar,日期模式为yyyy-MM(如2015-07、2015-06),我无法更改数据库中的此varchar日期模式 当我使用@DateTimeFormat(pattern=“yyyy-MM”)时,我得到的异常是 ERROR: org.hibernate.engine.jdbc.spi.SqlExceptionHelper - Bad format for DATE '2015-05' 如何在不更改数据库中的varchar日期

我对hibernate pojo注释有疑问。数据库中有一列是varchar,日期模式为yyyy-MM(如2015-07、2015-06),我无法更改数据库中的此varchar日期模式

当我使用
@DateTimeFormat(pattern=“yyyy-MM”)
时,我得到的异常是

 ERROR: org.hibernate.engine.jdbc.spi.SqlExceptionHelper - Bad format for DATE '2015-05'
如何在不更改数据库中的varchar日期模式的情况下解决这个问题

我在DB中进行了测试,varchar模式为(2015-07-01)和
@DateTimeFormat(pattern=“yyyy-MM-dd”)
没有异常。我用
@DateTimeFormat(pattern=“yyyy-MMM”)
测试模式(2015年5月),没有异常当模式为“yyyy-MM”时,它抛出此异常。不幸的是,我必须在数据库中使用此“2015-06”varchar模式,我如何解决此问题,hibernate批注似乎无法将此模式识别为“yyyy-MM”

我希望不要使用AttributeConverter,因为我不想为这个问题构建一个新类,它可能会使我的系统更加混乱