Announcement Announcement Module
Collapse
No announcement yet.
Could not determine type for: java.util.List, at table Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Could not determine type for: java.util.List, at table

    Hi All

    I 'm getting this problem,

    org.hibernate.MappingException: Could not determine type for: java.util.List, at table: User1, for columns: [org.hibernate.mapping.Column(user2)]
    org.hibernate.mapping.SimpleValue.getType(SimpleVa lue.java:292)
    org.hibernate.mapping.SimpleValue.isValid(SimpleVa lue.java:276)


    y User1 is

    package com.vaanila.domain;


    import javax.persistence.Column;
    import javax.persistence.Entity;
    import javax.persistence.GeneratedValue;
    import javax.persistence.Id;
    import javax.persistence.Table;
    import javax.persistence.FetchType;
    import java.sql.*;
    import com.vaanila.domain.User2;
    import java.util.*;
    //import org.hibernate.mapping.OneToMany;
    import java.lang.annotation.Annotation;
    import javax.persistence.OneToMany;
    import javax.persistence.CascadeType;
    import javax.persistence.Transient;
    import javax.persistence.JoinColumn;
    import javax.persistence.JoinTable;
    import javax.persistence.Access;
    import javax.persistence.AccessType;

    @Entity
    @org.hibernate.annotations.NamedNativeQuery(name = "se_user1", query = "call se_user1(?)", callable = true, resultClass = User1.class)
    @Table(name="User1")
    @Access(AccessType.FIELD)
    public class User1 implements java.io.Serializable {


    @Id

    @GeneratedValue

    @Column(name="USER_ID")

    private Long id;



    @OneToMany(mappedBy="user1",fetch=FetchType.EAGER, cascade={CascadeType.ALL},targetEntity=User1.class )
    @JoinTable(name = "USER1", joinColumns = { @JoinColumn(name = "USER_NAME") })
    //@JoinColumn(name="User_Name")
    @Column(name="USER_NAME")
    private String name;


    @Column(name="USER_PASSWORD")
    private String password;


    @Column(name="USER_GENDER")
    private String gender;


    @Column(name="USER_COUNTRY")
    private String country;


    @Column(name="USER_ABOUT_YOU")
    private String aboutYou;

    //private String[] community;

    //private Boolean mailingList;
    private List user2s;

    public User2 user2;



    public Long getId() {

    return id;

    }

    public void setId(Long id) {

    this.id = id;

    }




    public String getName() {

    return name;

    }

    public void setName(String name) {

    this.name = name;

    }





    public String getPassword() {

    return password;

    }

    public void setPassword(String password) {

    this.password = password;

    }





    public String getGender() {

    return gender;

    }

    public void setGender(String gender) {

    this.gender = gender;

    }





    public String getCountry() {

    return country;

    }

    public void setCountry(String country) {

    this.country = country;

    }





    public String getAboutYou() {

    return aboutYou;

    }

    public void setAboutYou(String aboutYou) {

    this.aboutYou = aboutYou;

    }

    //public User2 getUser2(User2 user2){
    // return user2;
    //}
    public void setUser2(User2 user2){
    this.user2=user2;
    }



    //@JoinColumn(name="User_Name")
    public List<User2> getUser2() {
    return user2s;
    }

    @Transient
    public void saveUser2(User2 user2) {
    this.user2=user2;
    user2.setUser1(this);
    user2s.add(user2);
    }


    /*
    @Column(name="USER_COMMUNITY")

    public String[] getCommunity() {

    return community;

    }

    public void setCommunity(String[] community) {

    this.community = community;

    }



    @Column(name="USER_MAILING_LIST")

    public Boolean getMailingList() {

    return mailingList;

    }

    public void setMailingList(Boolean mailingList) {

    this.mailingList = mailingList;

    }

    */
    }
    ************************
    And User2 is

    package com.vaanila.domain;


    import javax.persistence.Column;
    import javax.persistence.Entity;
    import javax.persistence.GeneratedValue;
    import javax.persistence.Id;
    import javax.persistence.Table;
    import java.sql.*;
    import com.vaanila.domain.User1;
    import javax.persistence.ManyToOne;
    import javax.persistence.JoinColumn;
    import javax.persistence.JoinTable;

    import javax.persistence.CascadeType;

    @Entity
    @Table(name="User2")
    public class User2 implements java.io.Serializable {



    public User1 user1;
    @Id
    @GeneratedValue
    @Column(name="USER_ID")
    private Long id;



    @ManyToOne(cascade={CascadeType.ALL}, targetEntity = User2.class)
    @JoinTable(name = "USER2", joinColumns = { @JoinColumn(name = "USER_NAME") })
    @Column(name="USER_NAME")
    private String name1;



    //private String[] community;

    //private Boolean mailingList;




    public Long getId() {
    return id;
    }
    public void setId(Long id) {
    this.id = id;
    }





    public String getName() {

    return name1;

    }
    public void setName(String name1) {

    this.name1 = name1;

    }


    //@JoinColumn(name="User_Name")

    public User1 getUser1() {
    return user1;
    }
    public void setUser1(User1 user1){
    this.user1=user1;
    }
    }


    Pl. tell me what am i doing wrong?

    Thanks & Regards
    Rajesh

  • #2
    Hello Rajesh

    1) use code tags, is more readable for us
    2) Read Hibernate Reference documentation. Your problem is not related with Spring.
    3) Use a Set instead of List
    4) Use parametized collections

    Comment


    • #3
      Thanks for your reply dr_p you pompeii.
      I will try what you said.
      Pl. tell me How to use code tags?
      Thanks
      Rajesh

      Comment


      • #4
        Hi

        Pl. tell me How to use code tags?
        Sure, when you write a post, above in the toolbar you have a icon (#) thats it

        Comment

        Working...
        X