-----Original Message-----
From: [EMAIL PROTECTED] [SMTP:[EMAIL PROTECTED]]
Sent: Friday, January 12, 2001 5:17 PM
To: jBoss
Subject: Re: [jBoss-User]??: [jBoss-User] Problem about CMP? Big Bug with JBoss CMP??
Hi,
� At the example,I want to insert two rows into table.
� �
� first row����� 19������������� White,Tallis,etc./Lamentations�� ������� �������
���second row 1�������������� Great Organ Works/Bach JS���������� Koopman���������������� classical, organ����������� Incl. Toccata & Fugue in D minor
������������field 1����field 2���������������������field 3��������������field 4������������ field 5
����������� id���������title�����������������������artist����������������type����������������notes�����
�
� from the log
�
������������[JAWS] Exists command executing: SELECT COUNT(*) FROM music_cd WHERE cd_id=?
����������� [JAWS] Set parameter: idx=1, jdbcType=CHAR, value=1
����������� [CDCollectionBean] Added CD with id=1, title=Great Organ Works/Bach JS, artist=Koopman, type=classical, organ, notes=Incl. Toccata & Fugue in D minor
����������� [JAWS] Create, id is 1
����������� [JAWS] Exists command executing: SELECT COUNT(*) FROM music_cd WHERE cd_id=?
����������� [JAWS] Set parameter: idx=1, jdbcType=CHAR, value=1
����������� [JAWS] Create command executing: INSERT INTO music_cd (cd_artist,cd_notes,cd_type,cd_title,cd_id) VALUES (?,?,?,?,?)
����������� [JAWS] Set parameter: idx=1, jdbcType=VARCHAR, value=NULL
����������� [JAWS] Set parameter: idx=2, jdbcType=VARCHAR, value=NULL
����������� [JAWS] Set parameter: idx=3, jdbcType=VARCHAR, value=NULL
����������� [JAWS] Set parameter: idx=4, jdbcType=VARCHAR, value=NULL
����������� [JAWS] Set parameter: idx=5, jdbcType=CHAR, value=1
����������� [JAWS] Rows affected = 1
����������� [CDCollectionBean] CDBean.ejbStore()
����������� [JAWS] Store command executing: UPDATE music_cd SET cd_artist=?,cd_notes=?,cd_type=?,cd_title=? WHERE cd_id=?
����������� [JAWS] Set parameter: idx=1, jdbcType=VARCHAR, value=Koopman
����������� [JAWS] Set parameter: idx=2, jdbcType=VARCHAR, value=Incl. Toccata & Fugue in D minor
����������� [JAWS] Set parameter: idx=3, jdbcType=VARCHAR, value=classical, organ
����������� [JAWS] Set parameter: idx=4, jdbcType=VARCHAR, value=Great Organ Works/Bach JS
����������� [JAWS] Set parameter: idx=5, jdbcType=CHAR, value=1
����������� [JAWS] Rows affected = 0
�
Yes, so what you have is a SELECT to check if the bean is there, an INSERT with mostly nulls to insert the row into the database with the correct primary key, which happens at ejbCreate, and an UPDATE to set the values in the row at the end of a tx, in ejbStore. What's not right here? It all looks good to me.
������������It's just corresponding to the codes as follows:
�����������
����������� �� public void addCd(String id, String title, String artist, String type, String notes) throws CDExistsException, RemoteException {
����������������� CDHome home = (CDHome) getHome("MyCD", CDHome.class);
������������������try {
��������������������� CD oldCd = home.findByPrimaryKey(id);
����������������������String dummy = oldCd.getId();�
����������������������throw new CDExistsException();
��������������������� }
����������������� catch (Exception e) {
�������������������� System.out.println("Added CD with id=" + id + ", title=" + title
�������������������������������+ ", artist=" + artist + ", type=" + type + ", notes=" + notes);
��������������������� try {
�������������������������� CD cd = home.create(id);
�������������������������� cd.setTitle(title);
�������������������������� cd.setArtist(artist);
�������������������������� cd.setType(type);
�������������������������� cd.setNotes(notes);
�������������������������� return;
������������������������� }
��������������������� catch (Exception e2) {
����������������������� throw new RemoteException (e2.toString());};
��������������������� }
�������������� }
�����������
����� "[CDCollectionBean] Added CD with id=1, title=Great Organ Works/Bach JS, artist=Koopman, type=classical, organ, notes=Incl. Toccata & Fugue in D minor" just means that the EJB will update�the table.
����� I'm afraid that you maybe made a mistake at looking at the log.
�
������[CDCollectionBean] Added CD with id=19, title=White,Tallis,etc./Lamentations, artist= , type= , notes=�
����� For the first row.��������
�
Which is what you were trying to put in, was it not?
����� [CDCollectionBean] Added CD with id=1, title=Great Organ Works/Bach JS, artist=Koopman, type=classical, organ, notes=Incl. Toccata & Fugue in D minor
����� For the second row.
Which is what you were trying to put in, was it not?
I fail to see why you are suprised that, when you create a bean with
id=19
title=White,Tallis,etc./Lamentations
artise=null
type=null
notes=null
as you seem to indicate in the table at the top of this mail, you are then suprised that the bean ends up with this data in it's fields, and that data then ends up in the database. GIGO, my friend ;-)
So what _is_ the problem you have with this behaviour?
Tom
