4 Replies Latest reply on Aug 14, 2012 3:47 PM by lukas lukasz

    Springmvc , problem with generics dao

    lukas lukasz Newbie

      Hello i have got wery big problem and plz help me it is first time when junit test its fine but if i use function in real program its not working (none errors)


      i create very simple GenericsDAO like that:


      public abstract class GenericDAO <T , PK extends Serializable> implements IGenericDAO<T, PK>
          protected EntityManager entityManager;
          protected Class<T> clazz;
          public GenericDAO(final Class<T> clazz)
              this.clazz = clazz;
          public void save(final T entity)
          public void delete(final T entity)


      It is very very simple generics dao as you see its one constructor with 1 attribute , next class must overwrite ...


      and i use standard simple example with member standard quickstart project in jboss



      public class MemberDaoImpl extends GenericDAO<Member, Long> implements MemberDao
          //default constructor start when object created
          public MemberDaoImpl() {
        //register first function persist
          public void register(Member member)


      as you see this class have got 1 default constructor and initialize superclass with element Memver.class


      And its very strange because my junit like that :



          //used method with generics save the same function as resister


      working fine but if i try use this function save in MemberController :



          public String registerNewMember(@Valid @ModelAttribute("newMember") Member newMember, BindingResult result, Model model)
              if (!result.hasErrors()) {
                  //we used generics method save 
                  //save is no working why ???


      Its not working why ??

      plz its very interesting for me because its first time when i used junit and everything is fine byt if i try use function in real app its problem :/


      additional info ;

      i used Jboss as 7.1 Thunder


      I attach very very simple project quickstart spring mvc with aditional generics dao and new test plz told me what is wrong , :/ i havent got any idea i spend 2 days and dont know :/...