kalo mo AUTO_INCREMENT jangan pake @GeneratedValue(strategy = GenerationType.AUTO)
tapi @GeneratedValue(strategy = GenerationType.IDENTITY) :D --- In jug-indonesia@yahoogroups.com, onsir salman <[EMAIL PROTECTED]> wrote: > > saya memiliki tabel groupuser dan user, dengan relasi one to many. > beikut : > tabel groupuser > ID_GROUP > DESCRIPTION > ACCESS > primary key id_group > > tabel user > ID_GROUP > ID_USER > USER_CODE > USER_NAME > PASSWORD > primary key user_code > foregin key id_group > > > > @Entity > @Table(name="t_groupuser") > > public class GroupUser implements java.io.Serializable{ > > @Id > @GeneratedValue(strategy = GenerationType.AUTO) > @Column(name="ID_GROUP") > private int idGroup; > @Column(name="DESCRIPTION",nullable=false,unique=true,length=25) > private String description; > @Column(name="ACCESS",nullable=false,length=500) > private String access; > @OneToMany(mappedBy="groupUser") > private List<User> user = new ArrayList<User>(); > ... > } > > > @Entity > @Table(name="t_user") > public class User implements java.io.Serializable { > > @Id > @GeneratedValue(strategy=GenerationType.AUTO) > @Column(name="ID_USER") > private int idUser; > @Column(name="USER_CODE",nullable=false,unique=true,length=15) > private String userCode; > @Column(name="USER_NAME",nullable=false,length=25) > private String userName; > @Column(name="PASSWORD",nullable=false,length=50) > private String password; > @ManyToOne > @JoinColumn(name="ID_GROUP") > private GroupUser groupUser; > ... > } > > private void btnSimpanActionPerformed(java.awt.event.ActionEvent evt) { > try{ > GroupUserHql groupUserHql = new GroupUserHql(); > GroupUser groupUser = new GroupUser(); > groupUser.setDescription(txtDescription.getText()); > groupUser.setAccess("aces"); > groupUserHql.save(groupUser); > }catch(Exception e){ > e.printStackTrace(); > } > } > > > lalu saya melakukan proses simpan data group user, pada saat di simpan error > spt ini. > tetapi [EMAIL PROTECTED](strategy = GenerationType.AUTO) tidak saya pakai data bisa di simpan. > bagaimana caranya agar bisa simpan data dgn Generated Value > > Hibernate: insert into t_groupuser (DESCRIPTION, ACCESS) values (?, ?) > org.hibernate.HibernateException: the database returned no natively generated identity value > at org.hibernate.id.IdentifierGeneratorFactory.getGeneratedIdentity(IdentifierGeneratorFactory.java:33) > at org.hibernate.id.IdentityGenerator$GetGeneratedKeysDelegate.executeAndExtract(IdentityGenerator.java:74) > at org.hibernate.id.insert.AbstractReturningDelegate.performInsert(AbstractReturningDelegate.java:33) > at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2093) > at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2573) > at org.hibernate.action.EntityIdentityInsertAction.execute(EntityIdentityInsertAction.java:47) > at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:248) > at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:290) > at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:180) > at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:108) > at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:186) > at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:175) > at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:98) > at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70) > at org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:507) > at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:499) > at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:495) > 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.hibernate.context.ThreadLocalSessionContext$TransactionProtectionWrapper.invoke(ThreadLocalSessionContext.java:301) > at $Proxy16.saveOrUpdate(Unknown Source) > at mst.hrd.hibernate.dao.hql.AbstractDao.saveOrUpdate(AbstractDao.java:29) > at mst.hrd.hibernate.dao.hql.GroupUserHql.create(GroupUserHql.java:29) > > > > > > > > > > > > > > Berbagi video sambil chatting dengan teman di Messenger >