I have a situation where I need to call a stored procedure when inserting data. We are heavily using annotations on this project so I definitely would like to use them for this situation. I have read up on the @SQLInsert annotation and I think it might work for me however I can't figure out the following:
1. How do I tell Hibernate which parameters are input parameters and which ones are output parameters?
2. How do I tell Hibernate in which order to pass the input parameters?
Below is hopefully enough information from my class to help you understand what I'm doing:
@SQLInsert(callable = true, sql = "call outbound_transaction_add_update(?, ?, ?, ?, ?, ?, ?, ?, ?)")
public class OutboundTransaction implements Timestampable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "outbound_transaction_id")
private Integer id;
@ManyToOne(cascade = { CascadeType.MERGE, CascadeType.PERSIST }, fetch = FetchType.LAZY)
@JoinColumn(name = "hcp_id")
private HealthCareProvider provider;
@Type(type = "EnumUserType", parameters = { @Parameter(name = "enumType", value = "OutboundTransactionType") })
@Column(name = "dict_outbound_transaction_type_code")
private OutboundTransactionType type;
@Column(name = "outbound_transaction_request_id")
private Integer outboundRequestId;
@Type(type = "EnumUserType", parameters = { @Parameter(name = "enumType", value = "OutboundTransactionStatus") })
@Column(name = "dict_transaction_status_code")
private OutboundTransactionStatus status;
@Column(name = "outbound_transaction_status_msg_str")
private String statusMessage;
@Column(name = "outbound_transaction_error_code")
private String errorCode;
@Column(name = "outbound_transaction_error_msg")
private String errorMessage;
private EntityTimestamp entityTimestamp;
}
|