@Entity
@Getter
@Setter
@Table(name = "product_wallet")
@NamedQuery(name = "ProductWallet.findAll", query = "SELECT pw FROM ProductWallet pw")
@EntityListeners(CUEntityListener.class)
public class ProductWallet implements Serializable, CUEntity {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "product_wallet_id", unique = true, nullable = false)
private Long productWalletId;
@Column
private Integer total;
@Column
private String status;
@Column(name = "user_id", updatable = false, insertable = false)
private String userId;
@Column(name = "member_id", updatable = false, insertable = false)
private Long memberId;
@Column(name = "provider_id", updatable = false, insertable = false)
private String providerId;
@Column(name = "created_by", length = 100)
private String createdBy;
@Column(name = "created_date")
private Timestamp createdDate;
@Column(name = "modified_by", length = 50)
private String modifiedBy;
@Column(name = "modified_date")
private Timestamp modifiedDate;
//bi-directional many-to-one association to MUser
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "user_id", referencedColumnName = "user_id")
private MUser user;
@OneToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "member_id")
private Member member;
@OneToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "provider_id")
private Provider provider;
@OneToMany(fetch = FetchType.LAZY, mappedBy = "productWallet")
private List<ProductWalletItem> productWalletItems;
Я пытаюсь использовать этот метод, используя автоматическое создание запроса с помощью JPA, написание запроса вручную и т. Д.
ProductWallet findProductWalletByProviderIdAndMemberId(String providerId, Long memberId);
, но по какой-то причине String providerId для всех преобразуется в Longиз них и я получаю эту ошибку. Кажется, что jdbc отчаянно пытается преобразовать что-то в Long:
Bad value for type long : PR_0000000288
2019-10-11 19:12:56 - Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.dao.DataIntegrityViolationException: could not execute query; SQL [select productwal0_.product_wallet_id as product_1_41_, productwal0_.created_by as created_2_41_, productwal0_.created_date as created_3_41_, productwal0_.member_id as member_i4_41_, productwal0_.modified_by as modified5_41_, productwal0_.modified_date as modified6_41_, productwal0_.provider_id as provider7_41_, productwal0_.status as status8_41_, productwal0_.total as total9_41_, productwal0_.user_id as user_id10_41_ from product_wallet productwal0_ where productwal0_.provider_id=? and productwal0_.member_id=?]; nested exception is org.hibernate.exception.DataException: could not execute query] with root cause
org.postgresql.util.PSQLException: Bad value for type long : PR_0000000288
at org.postgresql.jdbc.PgResultSet.toLong(PgResultSet.java:2860)
at org.postgresql.jdbc.PgResultSet.getLong(PgResultSet.java:2114)
at org.postgresql.jdbc.PgResultSet.getLong(PgResultSet.java:2506)
at com.zaxxer.hikari.proxy.HikariResultSetProxy.getLong(HikariResultSetProxy.java)
at org.hibernate.type.descriptor.sql.BigIntTypeDescriptor$2.doExtract(BigIntTypeDescriptor.java:63)
at org.hibernate.type.descriptor.sql.BasicExtractor.extract(BasicExtractor.java:47)