Hallo,
ich habe eine Entity Bean mit EJB3.0, die über einen zusammengesetzten Primary Key verfügt. Die beiden Key Felder nehmen jeweils noch als Foreign Key an einer Relation Teil.
@Entity
@Table(name = "jobitems")
@IdClass(JobItemId.class)
public class JobItem implements Serializable {
@ManyToOne
@JoinColumn(name = "forumId")
private Forum forum;
@ManyToOne
@JoinColumn(name = "parsingJobId")
private ParsingJob parsingJob;
@Id
@Column(name = "forumId", insertable = false, updatable = false)
private int forumId;
@Id
@Column(name = "parsingJobId", insertable = false, updatable = false)
private int parsingJobId;
private String server;
private String comments;
/**
* @param forum
* @param parsingJob
*/
public JobItem(Forum forum, ParsingJob parsingjob) {
super();
setForumId(forum.getId());
setParsingJobId(parsingjob.getId());
}
Wenn ich nun eine Instance anlegen möchte und diese zu persistieren versuche erhalte ich folgende Meldung:
2007-07-19 17:19:15,968 DEBUG [org.hibernate.SQL] insert into jobitems (server, comments, forumId, p
arsingJobId) values (?, ?, ?, ?)
2007-07-19 17:19:15,968 INFO [org.hibernate.type.IntegerType] could not bind value '1' to parameter
: 5; Parameter index out of range (5 > number of parameters, which is 4).
2007-07-19 17:19:15,968 DEBUG [org.hibernate.jdbc.AbstractBatcher] about to close PreparedStatement
(open PreparedStatements: 1, globally: 1)
2007-07-19 17:19:15,968 DEBUG [org.hibernate.jdbc.ConnectionManager] skipping aggressive-release due
to flush cycle
2007-07-19 17:19:15,968 DEBUG [org.hibernate.util.JDBCExceptionReporter] could not insert: [com.vico
.software.tools.parsing.entities.JobItem] [insert into jobitems (server, comments, forumId, parsingJ
obId) values (?, ?, ?, ?)]
java.sql.SQLException: Parameter index out of range (5 > number of parameters, which is 4).
at com.mysql.jdbc.SQLError.createSQLException(SQLErro r.java:910)
at com.mysql.jdbc.PreparedStatement.setInternal(Prepa redStatement.java:2740)
at com.mysql.jdbc.PreparedStatement.setInternal(Prepa redStatement.java:2771)
at com.mysql.jdbc.PreparedStatement.setInt(PreparedSt atement.java:2722)
at org.jboss.resource.adapter.jdbc.WrappedPreparedSta tement.setInt(WrappedPreparedStatement.java:11
7)
Für mich sieht es so aus als ob er alle 6 Felder der Klasse als Parameter übergeben will obwohl nur 4 Spalten für die Tabelle definiert sind. Hat jemand eine Idee wie das Problem zu lösen ist ?
Danke,
Philipp
ich habe eine Entity Bean mit EJB3.0, die über einen zusammengesetzten Primary Key verfügt. Die beiden Key Felder nehmen jeweils noch als Foreign Key an einer Relation Teil.
@Entity
@Table(name = "jobitems")
@IdClass(JobItemId.class)
public class JobItem implements Serializable {
@ManyToOne
@JoinColumn(name = "forumId")
private Forum forum;
@ManyToOne
@JoinColumn(name = "parsingJobId")
private ParsingJob parsingJob;
@Id
@Column(name = "forumId", insertable = false, updatable = false)
private int forumId;
@Id
@Column(name = "parsingJobId", insertable = false, updatable = false)
private int parsingJobId;
private String server;
private String comments;
/**
* @param forum
* @param parsingJob
*/
public JobItem(Forum forum, ParsingJob parsingjob) {
super();
setForumId(forum.getId());
setParsingJobId(parsingjob.getId());
}
Wenn ich nun eine Instance anlegen möchte und diese zu persistieren versuche erhalte ich folgende Meldung:
2007-07-19 17:19:15,968 DEBUG [org.hibernate.SQL] insert into jobitems (server, comments, forumId, p
arsingJobId) values (?, ?, ?, ?)
2007-07-19 17:19:15,968 INFO [org.hibernate.type.IntegerType] could not bind value '1' to parameter
: 5; Parameter index out of range (5 > number of parameters, which is 4).
2007-07-19 17:19:15,968 DEBUG [org.hibernate.jdbc.AbstractBatcher] about to close PreparedStatement
(open PreparedStatements: 1, globally: 1)
2007-07-19 17:19:15,968 DEBUG [org.hibernate.jdbc.ConnectionManager] skipping aggressive-release due
to flush cycle
2007-07-19 17:19:15,968 DEBUG [org.hibernate.util.JDBCExceptionReporter] could not insert: [com.vico
.software.tools.parsing.entities.JobItem] [insert into jobitems (server, comments, forumId, parsingJ
obId) values (?, ?, ?, ?)]
java.sql.SQLException: Parameter index out of range (5 > number of parameters, which is 4).
at com.mysql.jdbc.SQLError.createSQLException(SQLErro r.java:910)
at com.mysql.jdbc.PreparedStatement.setInternal(Prepa redStatement.java:2740)
at com.mysql.jdbc.PreparedStatement.setInternal(Prepa redStatement.java:2771)
at com.mysql.jdbc.PreparedStatement.setInt(PreparedSt atement.java:2722)
at org.jboss.resource.adapter.jdbc.WrappedPreparedSta tement.setInt(WrappedPreparedStatement.java:11
7)
Für mich sieht es so aus als ob er alle 6 Felder der Klasse als Parameter übergeben will obwohl nur 4 Spalten für die Tabelle definiert sind. Hat jemand eine Idee wie das Problem zu lösen ist ?
Danke,
Philipp