facebook

SpringMVC/Hibernate not able to insert into Oracle table

  1. MyEclipse IDE
  2.  > 
  3. Java EE Development (EJB, JSP, Struts, XDoclet, etc.)
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #349702 Reply

    John Ramacciotti
    Participant

    I am using ME 2014 (Bling). I have an Oracle 11g database. I have a single table I am attempting to scaffold using “Scaffold Spring CRUD Application” from the MyEclipse menu. The scaffold creates the application code and runs inside MyEclipse (Tomcat 7). The Oracle table as an Id column (int) and there is a sequence and trigger that inserts the sequence.nextval into the id column.
    In the domain (POJO) class, the annotation for the id column is:
    @GeneratedValue()
    @Id
    @Column(name = “DOC_ID”, precision = 15, nullable = false, unique = true)
    @Basic(optional = false)
    @SequenceGenerator(sequenceName = “DOC_S1”, name = “DOC_S1”)
    @XmlElement
    Integer docId;
    /**
    */
    I am getting this error message: “java.sql.SQLSyntaxErrorException: ORA-02289: sequence does not exist”
    I am using jdk 1.7 and the db driver is “ojdbc6.jar”

    #349719 Reply

    jpramac,

    You need to add schemaname.sequencename / databasename.sequencename for the sequenceName attribute under @SequenceGenerator annotation to get it working.

    Here is the code that I added in my domain (POJO) class and got it working :

    @Id
    @Column(name = “id”, nullable = false, unique = true)
    @Basic(fetch = FetchType.EAGER)
    @GeneratedValue(strategy=GenerationType.SEQUENCE, generator=”my_seq”)
    @SequenceGenerator(name=”my_seq”,sequenceName=”TestSchema.DEPT_SEQ”,allocationSize=1)
    @XmlElement
    Integer id;

    Let us know how it works for you.

Viewing 2 posts - 1 through 2 (of 2 total)
Reply To: SpringMVC/Hibernate not able to insert into Oracle table

You must be logged in to post in the forum log in