1 Reply Latest reply on Jan 16, 2007 7:30 AM by wolfgangknauf

    mapping example onetoMany

    trashhash

      Dose any one got an easy example for mapping tables/objects? This is what Im manage to do so far.

      
      public class Team (...)
      @OneToMany(mappedBy="team")
       private List teamList;
      
      public class User (...)
      
      @ManyToOne
      @JoinColumn(name="team_id",referencedColumnName="id")
      protected User user;
      
      

      referencedColumnName="id" id column for table user.
      name = id column for table team.

      All im getting is

       javax.persistence.PersistenceException: org.hibernate.MappingException: Could not determine type for: java.util.List, for columns: [org.hibernate.mapping.Column(user)]
      


      Its strange that Column contains the class name?

      Do I need to add something to persistence.xml?

        • 1. Re: mapping example onetoMany
          wolfgangknauf

          Hi !

          I think you have to use a generic list so that the container can determine which type is contained in the list:

          public class Team (...)
          @OneToMany(mappedBy="team")
          private List<User> teamList;


          The snippet of class "User" seems to be wrong, you probably meant this:
          public class User (...)
          
          @ManyToOne
          @JoinColumn(name="team_id",referencedColumnName="id")
          protected Team team;


          Hope this helps

          Wolfgang