为了将对象持久化到postgres db,我使用的是一个注意到的类而不是xml文件。下面是使用的模板类。
import java.sql.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;
@Entity
@Table(name = "ABCD", catalog = "XYZ", uniqueConstraints = {
@UniqueConstraint(columnNames = "FILE_REF_NO") })
public class MCT112_InputFAT implements java.io.Serializable {
@Id
@Column(name = "FILE_REF_NO", unique = true, nullable = false)
private String fileRefNo;
@Column(name = "FILE_NAME")
private String fileName;
@Column(name = "FILE_DATE")
private Date fileDate;
@Column(name = "FILE_PROCESSED_DATE")
private Date processedDate;
@Column(name = "PROCESSED_STATUS")
private Boolean processedStatus;
@Column(name = "FILLER1")
private Date filler1;
@Column(name = "FILLER2")
private String filler2;
@Column(name = "FILLER3")
private String filler3;
@Column(name = "FILLER4")
private Integer filler4;
@Column(name = "FILLER5")
private Integer filler5;
public MCT112_InputFAT() {
}
public MCT112_InputFAT(String fileRefNo, String fileName, Date fileDate, Date processedDate,
Boolean processedStatus, Date filler1, String filler2, String filler3, Integer filler4, Integer filler5) {
super();
this.fileRefNo = fileRefNo;
this.fileName = fileName;
this.fileDate = fileDate;
this.processedDate = processedDate;
this.processedStatus = processedStatus;
this.filler1 = filler1;
this.filler2 = filler2;
this.filler3 = filler3;
this.filler4 = filler4;
this.filler5 = filler5;
}
public String getFileRefNo() {
return fileRefNo;
}
public void setFileRefNo(String fileRefNo) {
this.fileRefNo = fileRefNo;
}
public String getFileName() {
return fileName;
}
public void setFileName(String fileName) {
this.fileName = fileName;
}
public Date getFileDate() {
return fileDate;
}
public void setFileDate(Date fileDate) {
this.fileDate = fileDate;
}
public Date getProcessedDate() {
return processedDate;
}
public void setProcessedDate(Date processedDate) {
this.processedDate = processedDate;
}
public Boolean getProcessedStatus() {
return processedStatus;
}
public void setProcessedStatus(Boolean processedStatus) {
this.processedStatus = processedStatus;
}
public Date getFiller1() {
return filler1;
}
public void setFiller1(Date filler1) {
this.filler1 = filler1;
}
public String getFiller2() {
return filler2;
}
public void setFiller2(String filler2) {
this.filler2 = filler2;
}
public String getFiller3() {
return filler3;
}
public void setFiller3(String filler3) {
this.filler3 = filler3;
}
public Integer getFiller4() {
return filler4;
}
public void setFiller4(Integer filler4) {
this.filler4 = filler4;
}
public Integer getFiller5() {
return filler5;
}
public void setFiller5(Integer filler5) {
this.filler5 = filler5;
}
}`
但是运行这些值在sql字符串中填充为空,如下所示。
insert into XYZ.ABCD(FILE_NAME, FILE_DATE, FILE_PROCESSED_DATE, PROCESSED_STATUS, FILLER1, FILLER2, FILLER3, FILLER4, FILLER5, FILE_REF_NO) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
有谁知道这里有什么问题。
答案 0 :(得分:1)
默认情况下,Hibernate使用基本的日志记录功能(启用了show_sql属性),它不显示请求参数。
如果您需要请求参数,则必须使用log4j库并将 logger log4j.logger.org.hibernate.type 置于 TRACE 级别。
请参阅下面的log4j.properties示例(对于log4j 1.2):
# Send log messages to stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
# Root logger option
log4j.rootLogger=INFO, stdout
# Display only startup messages
log4j.logger.org.hibernate=INFO
# same as show_sql=true
log4j.logger.org.hibernate.SQL=DEBUG
# display bind parameter
log4j.logger.org.hibernate.type=TRACE