I really can't seem to figure this out.
I'm going to post my source code:
UserInterest
Code:
package com.tkassembled.data ;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import org.red5.io.amf3.IDataInput;
import org.red5.io.amf3.IDataOutput;
import org.red5.io.amf3.IExternalizable;
/**
*
*/
@Entity @Table(name = "userinterest")
public class UserInterest implements IExternalizable
{
/**
* @private
*/
@Id @GeneratedValue @Column(name = "id")
private Integer id;
/**
* @private
*/
@Column(name = "realm")
private Integer realm = 999;
/**
* @private
*/
@Column(name = "level")
private Integer level = 0;
/**
* @private
*/
@Column(name = "years")
private Integer years = 0;
/**
* Contains values for a User's realms of interest.
*/
public UserInterest()
{
}
/**
* @see IExternalizable
*/
public void readExternal(IDataInput input)
{
this.id = input.readInt();
this.realm = input.readInt();
this.level = input.readInt();
this.years = input.readInt();
}
/**
* @see IExternalizable
*/
public void writeExternal(IDataOutput output)
{
output.writeInt(this.id);
output.writeInt(this.realm);
output.writeInt(this.level);
output.writeInt(this.years);
}
public Integer getId() {return this.id;}
public void setId(Integer id) { this.id = id; }
public Integer getRealm() { return realm; }
public void setRealm(Integer realm) { this.realm = realm; }
public Integer getLevel() { return level; }
public void setLevel(Integer level) { this.level = level; }
public Integer getYears() { return years; }
public void setYears(Integer years) { this.years = years; }
}
Again, this is an entry in a collection that I've defined in my User class as so:
Code:
@OneToMany
@JoinTable(
name="users_userinterests",
joinColumns = @JoinColumn(name = "user_id", unique = false),
inverseJoinColumns = @JoinColumn(name = "interest_id", unique = false)
)
And, for kicks, here's my Hibernate output and errors:
Quote:
Hibernate:
insert
into
users
(avatar, country, dob, email, full_name, gender, password, privacy, sign_up_date, username)
values
(?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
Hibernate:
insert
into
users_userinterests
(user_id, interest_id)
values
(?, ?)
Hibernate:
insert
into
users_userinterests
(user_id, interest_id)
values
(?, ?)
Hibernate:
insert
into
users_userinterests
(user_id, interest_id)
values
(?, ?)
org.springframework.dao.DataIntegrityViolationException: Hibernate operation: Could not execute JDBC batch update; SQL [insert into users_userinterests (user_id, interest_id) values (?, ?)]; Duplicate entry '0' for key 1; nested exception is java.sql.BatchUpdateException: Duplicate entry '0' for key 1
Caused by: java.sql.BatchUpdateException: Duplicate entry '0' for key 1
at com.mysql.jdbc.ServerPreparedStatement.executeBatch(ServerPreparedStatement.java:657)
at org.apache.commons.dbcp.DelegatingStatement.executeBatch(DelegatingStatement.java:297)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:48)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:246)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:266)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:171)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
at org.springframework.orm.hibernate3.HibernateAccessor.flushIfNecessary(HibernateAccessor.java:390)
at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:373)
at org.springframework.orm.hibernate3.HibernateTemplate.save(HibernateTemplate.java:632)
at com.tkassembled.database.UserDAOImpl.persistUser(UserDAOImpl.java:52)
at com.tkassembled.service.HibernateServiceImpl.persistUser(HibernateServiceImpl.java:45)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:304)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:198)
at $Proxy28.persistUser(Unknown Source)
at com.tkassembled.RemotingHandler.persistUser(RemotingHandler.java:28)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.red5.server.service.ServiceInvoker.invoke(ServiceInvoker.java:217)
at org.red5.server.service.ServiceInvoker.invoke(ServiceInvoker.java:123)
at org.red5.server.net.rtmp.RTMPHandler.invokeCall(RTMPHandler.java:157)
at org.red5.server.net.rtmp.RTMPHandler.onInvoke(RTMPHandler.java:409)
at org.red5.server.net.rtmp.BaseRTMPHandler.messageReceived(BaseRTMPHandler.java:143)
at org.red5.server.net.rtmp.RTMPMinaIoHandler.messageReceived(RTMPMinaIoHandler.java:119)
at org.apache.mina.common.support.AbstractIoFilterChain$TailFilter.messageReceived(AbstractIoFilterChain.java:570)
at org.apache.mina.common.support.AbstractIoFilterChain.callNextMessageReceived(AbstractIoFilterChain.java:299)
at org.apache.mina.common.support.AbstractIoFilterChain.access$1100(AbstractIoFilterChain.java:53)
at org.apache.mina.common.support.AbstractIoFilterChain$EntryImpl$1.messageReceived(AbstractIoFilterChain.java:648)
at org.apache.mina.filter.executor.ExecutorFilter.processEvent(ExecutorFilter.java:220)
at org.apache.mina.filter.executor.ExecutorFilter$ProcessEventsRunnable.run(ExecutorFilter.java:264)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907)
at java.lang.Thread.run(Thread.java:619)
Help is extremely appreciated in this. I'm totally hung up on development until I can get this done. Looks like it's gonna be a long day today and it's already 6pm :/