[jboss-user] [JBoss Seam] - Re: ManyToOne OneToMany

jknotzke do-not-reply at jboss.com
Wed Aug 8 22:25:41 EDT 2007


  Right.. That did it. Thanks.

   Next bug.

   Just to set the stage, an Athlete can have several workouts. I am able to create an athlete and it's stored in the DB. After which, I attempt to create a Workout. A workout however is created when a user uploads a CSV file of their workout.

   I am able to parse this, load it into the Workout Entity bean. However, I want to be able to associate this with the athlete that was previously select.. Here is the code:

  | @Stateless
  | @Scope(SESSION)
  | @Name("uploadWorkout")
  | public class UploadWorkoutBean implements UploadWorkout
  | {
  | 
  | 	@Logger
  | 	private Log log;
  | 
  | 	@In Athlete athlete;
  | 
  | 	@In(value = "uploadedWorkout", create = true)
  | 	private UploadedWorkout uploadedWorkout;
  | 
  | 	@In
  | 	FacesMessages facesMessages;
  | 
  |    @PersistenceContext 
  |    private EntityManager em;
  | 
  | 	public void uploadWorkout()
  | 	{
  | 		// implement your business logic here
  | 		log.info("uploadWorkout.uploadWorkout() action called");
  | 		log.info("Content Type is: " + uploadedWorkout.getContentType());
  | 		log.info("FileName is: " + uploadedWorkout.getFileName());
  | 
  | 		WorkoutReader workoutReader = new WorkoutReader();
  | 
  | 		ArrayList<Workout> workouts = workoutReader.readFile(uploadedWorkout.getUploadedFile());
  | 		Workout workout = null;
  |                 // Stuff it into the DB
  | 
  | 		for(int i=0; i< 1 ;i++)
  | 		{
  | 	 	    workout = workouts.get(i);
  | 		    log.info(athlete.getLastName());
  | 		    em.persist(workout);
  | 		}
  | 		
  | 		facesMessages.add("uploadWorkout");
  | 	}
  | 

   The error that is thrown is:



  | Caused by: org.jboss.seam.RequiredException: In attribute requires non-null value: uploadWorkout.athlete
  |         at org.jboss.seam.Component.getValueToInject(Component.java:2153)
  |         at org.jboss.seam.Component.injectAttributes(Component.java:1583)
  |         at org.jboss.seam.Component.inject(Component.java:1404)
  |         at org.jboss.seam.core.BijectionInterceptor.aroundInvoke(BijectionInterceptor.java:45)
  |         at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
  |         at org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:42)
  |         at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
  |         at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:106)
  |         at org.jboss.seam.intercept.SessionBeanInterceptor.aroundInvoke(SessionBeanInterceptor.java:53)
  |         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)
  | 
  | 

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4072272#4072272

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4072272



More information about the jboss-user mailing list