[jboss-user] [Persistence, JBoss/CMP, Hibernate, Database] - Re: setParameter() IllegalArgumentException

NSchweig do-not-reply at jboss.com
Wed Dec 24 06:08:14 EST 2008


Solution:

CourseHandler:

  | public List<Course> getCoursesForInstructor(CmtUser instructor){
  | 		try{
  | 			Query q = em.createQuery(
  | 					"SELECT c FROM Course c" +
  | 					" WHERE c.instructor = :instructor");
  | 					q.setParameter("instructor",instructor);
  | 
  | 			 List<Course> courses =	(List<Course>) q.getResultList(); 
  | 			 return courses ;
  | 
  | 		}
  | 
  | 		catch(EntityNotFoundException ex){
  | 			System.out.println("FEHLER!!!!"+ex);
  | 		}
  | 		return null;
  | 	}

Course:
@Entity
  | public class Course implements Serializable{
  | 	@Id
  | 	@GeneratedValue(strategy = GenerationType.AUTO)
  | 	private Long id;
  | 	
  | 	private String title;
  | 	private String abbreviation;
  | 	private String description;
  | 	private String semester;
  | 	@Column(columnDefinition="BOOL") 
  | 	private boolean active = false;
  | 
  | 	//unidirektional
  | 	@ManyToOne
  | 	@JoinColumn(name="instructor")
  | 	private CmtUser instructor;
  | ...


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

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



More information about the jboss-user mailing list