hibernate

How to change the Hibernate CharacterTypeDescriptor to handle empty column values

…衆ロ難τιáo~ 提交于 2021-01-21 07:22:05
问题 Our problem is that we can't get data (which includes empty strings with length 0) from a legacy database due to a StringIndexOutOfBoundsExceptiion originating from Hibernate's CharacterTypeDescriptor . We would like to change Hibernate's behavior to properly resolve empty strings. Example data: 1, 'Berlin', 17277, '', 'aUser' 2, 'London', 17277, '', 'anotherUser' We use hibernate with javax.persistence.Query . String sql = "SELECT * FROM table"; Query query = entityManager.createNativeQuery

How to change the Hibernate CharacterTypeDescriptor to handle empty column values

折月煮酒 提交于 2021-01-21 07:19:55
问题 Our problem is that we can't get data (which includes empty strings with length 0) from a legacy database due to a StringIndexOutOfBoundsExceptiion originating from Hibernate's CharacterTypeDescriptor . We would like to change Hibernate's behavior to properly resolve empty strings. Example data: 1, 'Berlin', 17277, '', 'aUser' 2, 'London', 17277, '', 'anotherUser' We use hibernate with javax.persistence.Query . String sql = "SELECT * FROM table"; Query query = entityManager.createNativeQuery

How to change the Hibernate CharacterTypeDescriptor to handle empty column values

爷,独闯天下 提交于 2021-01-21 07:19:10
问题 Our problem is that we can't get data (which includes empty strings with length 0) from a legacy database due to a StringIndexOutOfBoundsExceptiion originating from Hibernate's CharacterTypeDescriptor . We would like to change Hibernate's behavior to properly resolve empty strings. Example data: 1, 'Berlin', 17277, '', 'aUser' 2, 'London', 17277, '', 'anotherUser' We use hibernate with javax.persistence.Query . String sql = "SELECT * FROM table"; Query query = entityManager.createNativeQuery

Spring Data Rest: “Date is null” query throws an postgres exception

笑着哭i 提交于 2021-01-21 06:37:08
问题 I use Spring Boot and Data Rest to create a simple microservice in Java8 and get a postgres exception. My entity: @Entity public class ArchivedInvoice implements Serializable { ... @Column private String invoiceNumber; @Column private java.sql.Date invoiceDate; ... } My repository interface: @RepositoryRestResource(collectionResourceRel = "archivedinvoices", path = "archivedinvoices") public interface ArchivedInvoiceRepository extends PagingAndSortingRepository < ArchivedInvoice, Long > { ...

How to encrypt a column in Postgres using Hibernate @ColumnTransformer

穿精又带淫゛_ 提交于 2021-01-20 19:25:55
问题 I am trying to encrypt a column in my prostrgres DB. The column name is "test" of type "bytea". My enity code is below, @ColumnTransformer( forColumn="test", read="pgp_sym_encrypt(test::bytea, 'mySecretKey')", write="pgp_sym_decrypt(?, 'mySecretKey')") private String test; When I tried to retrieve the entity, I am getting the encrypted data like below. How do I get the decrypted value programmatically? But I get the actual value If i execute a postgres select query. "test": "\

How to encrypt a column in Postgres using Hibernate @ColumnTransformer

北战南征 提交于 2021-01-20 19:22:02
问题 I am trying to encrypt a column in my prostrgres DB. The column name is "test" of type "bytea". My enity code is below, @ColumnTransformer( forColumn="test", read="pgp_sym_encrypt(test::bytea, 'mySecretKey')", write="pgp_sym_decrypt(?, 'mySecretKey')") private String test; When I tried to retrieve the entity, I am getting the encrypted data like below. How do I get the decrypted value programmatically? But I get the actual value If i execute a postgres select query. "test": "\

How to encrypt a column in Postgres using Hibernate @ColumnTransformer

北城余情 提交于 2021-01-20 19:21:00
问题 I am trying to encrypt a column in my prostrgres DB. The column name is "test" of type "bytea". My enity code is below, @ColumnTransformer( forColumn="test", read="pgp_sym_encrypt(test::bytea, 'mySecretKey')", write="pgp_sym_decrypt(?, 'mySecretKey')") private String test; When I tried to retrieve the entity, I am getting the encrypted data like below. How do I get the decrypted value programmatically? But I get the actual value If i execute a postgres select query. "test": "\

hibernate.enable_lazy_load_no_trans is not working

那年仲夏 提交于 2021-01-20 07:45:31
问题 I'm using JPA2.1 and hibernate 4.3.8 and i have configured the presistence.xml to allow lazy loading i have added <property name="hibernate.enable_lazy_load_no_trans" value="true" /> into properties section but i'm still getting LazyInitializtionException, what is the problem ? 回答1: The hibernate.enable_lazy_load_no_trans is an anti-pattern and you should never use it because a database connection is needed for every lazy association that is fetched outside of the initial Persistence Context,

Microsoft SQL variant type error pops up when I run hibernate 5

混江龙づ霸主 提交于 2021-01-20 04:51:46
问题 Whenever I run my hibernate 5, I see this error: ERROR: Could not fetch the SequenceInformation from the database com.microsoft.sqlserver.jdbc.SQLServerException: The "variant" data type is not supported. I've never heard of a "variant" data type before. Or is it a category of data types? Not sure. I checked the data types in all my tables, and these are the ones that are there: bigint, bit, date, datetime, int, numeric, varbinary, and varchar. Where could this error be coming from? Is there

基于SSH的预约挂号系统之公告模块

谁都会走 提交于 2021-01-20 01:33:31
后台管理页面 创建一个公告的 JavaBean private Integer noticeId;//公告Id private String title;//标题 private String text;//内容 private Admin author;//发布人 private Date createTime;//创建时间 private Date updateTime;//最后一次修改时间 private Integer isShow;//是否在前端页面展示 映射文件 Notice.hbm.xml <hibernate-mapping> <class name="com.zhc.entities.Notice" table="NOTICE"> <id name="noticeId" type="java.lang.Integer"> <column name="NOTICE_ID" /> <generator class="native" /> </id> <property name="title" type="java.lang.String"> <column name="TITLE" /> </property> <property name="text" type="java.lang.String"> <column name="TEXT" sql-type=