4 Replies Latest reply on Jul 29, 2005 5:50 PM by epbernard

    String column as identifier fail,note that it's not Integer

    epbernard

      I should not fail, but you don't give enough info for us to help.

        • 1. Re: String column as identifier fail,note that it's not Inte
          jvava

           

          "epbernard" wrote:
          I should not fail, but you don't give enough info for us to help.


          thanks.
          now i will describe the procedure in detail.
          step 1,i trid the entity example in the turtorial with the installing and go very well.
          step 2, i alter the the int column which marked with id anotation into String type.and modify the client.java accrodingly.
          step 3,i build and deploy it again,now all go well.
          step 4,i run the client which create a Entity and perisit it.it threw Exception,message is like "ids must be set manully before called save()";

          my god,who can help me.i found all example use a int column as identifier except composite identifier whick is not for me.

          • 2. Re: String column as identifier fail,note that it's not Inte
            epbernard

            "ids must be set manully before called save()"
            It's a String, so there is no generator strategy available so you need to set the id string before giving the object to the entity manager

            • 3. Re: String column as identifier fail,note that it's not Inte
              jvava

              seems that i've set it certainly.


              TestEntity.java
              ....
              @Id
              public String getName() { retrun name; }
              public void setName(String s) { name = s; }
              ...
              TestClient.java
              ...
              TestEntity test = new TestEntity();
              test.setName("a");
              test.setAge(10);
              ...
              em.persist(test);

              is this right?i do set it,but it tell me "ids must be set...".

              thanks again.

              • 4. Re: String column as identifier fail,note that it's not Inte
                epbernard

                Well this is not the actual code you used to test it, it does not compile.
                I've added a unit test and it's working fine for me.