I thought that it's the db sets the value for calendar's pk in ejbCreate. If your code does it then it's ok.
alex Thursday, November 14, 2002, 4:02:01 PM, you wrote: k> Alex I'didn't understand about pk generator. k> As you have suggested I'm already using a Sequence gen session bean. k> I've put those directives on db, as redundant code. k> Ps.: k> You are a mith, thx very much ! ;-) k> Alex Loubyansky wrote: >>k> Alex, I've found the problem >>k> if calendar id is 0 it doesn't work. >> >>If it's the only problem, then checkout a fresh version from CVS. >>I fixed it yesterday in 3.0, 3.2 and HEAD. >> >>How do you obtain a Calendar before doing >>wHome.create( pView, lCalendar )? >> >>There is no guarantee that calendar will have the correct pk value with >>such a table setup. This is why I warned you that, generally, it won't >>work. >>I suggest you to implement your own sequence generator pattern (or ask >>me to share mine :)) or use pk-sql entity-command. >> >>alex >> >>Thursday, November 14, 2002, 3:17:44 PM, you wrote: >> >>k> Alex, I've found the problem >> >>k> if calendar id is 0 it doesn't work. >> >>k> But I can't understand why? I've never read about it. >> >>k> Alex Loubyansky wrote: >> >>>>AFAIK, generally, this won't work. >>>> >>>>If you would like to make use of db sequences consider pk-sql entity >>>>command. But it's available since 3.2. >>>> >>>>Anyway, try to fetch calendar's pk before assigning a relationship and >>>>see what value it has. Post the results here, please. >>>> >>>>alex >>>> >>>>Thursday, November 14, 2002, 1:36:16 PM, you wrote: >>>> >>>>k> Thx for your attention Alex, >>>> >>>>k> this is a piece o sql (postgresql) I use to create tables. >>>> >>>>k> --calendar section-- >>>>k> CREATE SEQUENCE calendar_seq; >>>>k> CREATE TABLE calendar ( >>>>k> id INTEGER DEFAULT nextval('calendar_seq'), >>>>k> validity_start date NOT NULL, >>>>k> validity_end date CHECK(validity_end >= validity_start), >>>>k> description varchar(255) NOT NULL, >>>>k> rounds INTEGER, >>>>k> PRIMARY KEY (id) >>>>k> ); >>>>k> CREATE UNIQUE INDEX cal_descr_ix ON calendar(description); >>>> >>>>k> CREATE SEQUENCE workweek_seq; >>>>k> CREATE TABLE workweek ( >>>>k> id INTEGER DEFAULT nextval('workweek_seq') PRIMARY KEY, >>>>k> week_day INTEGER DEFAULT 1, >>>>k> round INTEGER, >>>>k> start_t time DEFAULT('00:00') NOT NULL, >>>>k> end_t time DEFAULT('23:59') CHECK (end_t > start_t), >>>>k> calendar_id INTEGER REFERENCES calendar(id) >>>>k> ); >>>> >>>> >>>>k> while in bean generated calendarPk is >>>> >>>>k> public CalendarPK( int id ) >>>>k> { >>>>k> this.id = id; >>>>k> } >>>> >>>>k> generated from >>>> >>>>k> /** >>>>k> * Retrieve the Calendars's id. >>>>k> * >>>>k> * @return Returns the id of this Calendar. >>>>k> * @ejb.persistent-field >>>>k> * @ejb.pk-field >>>>k> * @jboss.column-name >>>>k> * name="id" >>>>k> */ >>>>k> public abstract int getId(); >>>> >>>>k> /** >>>>k> * Sets the Calendar's id. >>>>k> * >>>>k> * @param pId The id of this Calendar. >>>>k> */ >>>>k> public abstract void setId(int pId); >>>> >>>>k> I've consulted some manuals but I can's see the problem. >>>> >>>> >>>>k> Alex Loubyansky wrote: >>>> >>>>>>Hello kiuma, >>>>>> >>>>>>what is the type of Calendar's primary key? What pk values you tried? >>>>>> >>>>>>alex >>>>>> >>>>>>Thursday, November 14, 2002, 11:38:27 AM, you wrote: >>>>>> >>>>>>k> I've tryed also setting the post create method, but whit no result. >>>>>> >>>>>>k> public WorkweekPK ejbCreate( WorkweekData pWorkweek, CalendarLocal >>>>>>k> lCalendar ) >>>>>>k> throws >>>>>>k> InvalidValueException, >>>>>>k> EJBException, >>>>>>k> CreateException >>>>>>k> { >>>>>>k> // Clone the given Value Object to keep changed private >>>>>>k> WorkweekData lData = (WorkweekData) pWorkweek.clone(); >>>>>> >>>>>>k> // Save the new Workweek >>>>>>k> try { >>>>>>k> lData.setId( generateUniqueId() ); >>>>>>k> setId( lData.getId() ); >>>>>>k> } catch (ServiceUnavailableException e) { >>>>>>k> System.out.println("Workweek Creation Error: \n" + >>>>>>k> e.getMessage()); >>>>>>k> throw new EJBException(e.getMessage()); >>>>>>k> } >>>>>>k> setValueObject( lData ); >>>>>>k> // This is only possible in CMPs. Otherwise return a valid PK. >>>>>>k> return null; >>>>>>k> } >>>>>> >>>>>>k> /** >>>>>>k> */ >>>>>>k> public void ejbPostCreate( WorkweekData pWorkweek, CalendarLocal lCalendar ) >>>>>>k> { >>>>>>k> setCalendar( lCalendar ); >>>>>>k> } >>>>>> >>>>>> >>>>>>k> In my database calendar_id is always clean. >>>>>> >>>>>>k> Please help me!!!! >>>>>> >>>>>> >>>>>> >>>>>>k> kiuma wrote: >>>>>> >>>>>>>>Hi I'm using jboss3.2b + xdoclet cvs >>>>>>>> >>>>>>>>I've a calendar with many workweek days >>>>>>>> >>>>>>>>so I configured xdoclet directives for >>>>>>>> >>>>>>>>WorkweekBean >>>>>>>>/** >>>>>>>> * @ejb.interface-method >>>>>>>> * view-type="local" >>>>>>>> * @ejb.relation >>>>>>>> * name="calendar-workweeks" >>>>>>>> * role-name="workweek-has-calendar" >>>>>>>> * cascade-delete="yes" >>>>>>>> * target-ejb="Calendar" >>>>>>>> * @jboss.relation >>>>>>>> * fk-constraint="true" >>>>>>>> * fk-column="calendar_id" >>>>>>>> * related-pk-field="id" >>>>>>>> */ >>>>>>>>public abstract CalendarLocal getCalendar(); >>>>>>>> >>>>>>>> /** >>>>>>>> * @ejb.interface-method >>>>>>>> * view-type="local" >>>>>>>> */ >>>>>>>> public abstract void setCalendar(CalendarLocal pCalendarData); >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>>while for >>>>>>>>CalendarBean >>>>>>>> >>>>>>>>/** >>>>>>>> * @ejb.relation >>>>>>>> * name="calendar-workweeks" >>>>>>>> * role-name="calendar-has-workweeks" >>>>>>>> * @ejb.interface-method >>>>>>>> * view-type="local" >>>>>>>> */ >>>>>>>> public abstract Collection getWorkweeks(); /** >>>>>>>> * @ejb.interface-method >>>>>>>> * view-type="local" >>>>>>>> */ >>>>>>>> public abstract void setWorkweeks(Collection pHolydays); >>>>>>>> >>>>>>>> >>>>>>>>when in my session I execute the following commands >>>>>>>>WorkweekLocal wEntity = wHome.create( pView ); >>>>>>>>wEntity.setCalendar( lCalendar ); >>>>>>>> >>>>>>>>Workweek is created, but no calendar_id is set. >>>>>>>>Could you help me please ? >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>>the piece of the generated jboss_cmp is: >>>>>>>><ejb-relation> >>>>>>>> <ejb-relation-name>calendar-workweeks</ejb-relation-name> >>>>>>>> >>>>>>>> <foreign-key-mapping/> >>>>>>>> >>>>>>>> <ejb-relationship-role> >>>>>>>> >>>>>>>><ejb-relationship-role-name>workweek-has-calendar</ejb-relationship-role-name> >>>>>>>> >>>>>>>> <fk-constraint>true</fk-constraint> >>>>>>>> <key-fields/> >>>>>>>> </ejb-relationship-role> >>>>>>>> <ejb-relationship-role> >>>>>>>> >>>>>>>><ejb-relationship-role-name>calendar-has-workweeks</ejb-relationship-role-name> > >>>>>>>> >>>>>>>> <key-fields> >>>>>>>> <key-field> >>>>>>>> <field-name>id</field-name> >>>>>>>> <column-name>calendar_id</column-name> >>>>>>>> </key-field> >>>>>>>> </key-fields> >>>>>>>> </ejb-relationship-role> -- Best regards, Alex Loubyansky ------------------------------------------------------- This sf.net email is sponsored by: To learn the basics of securing your web site with SSL, click here to get a FREE TRIAL of a Thawte Server Certificate: http://www.gothawte.com/rd524.html _______________________________________________ JBoss-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jboss-user