AnsweredAssumed Answered

Error creating new / my first table using SimpleDAO

Question asked by anlu on Feb 20, 2017
Latest reply on Mar 9, 2017 by as0045500

Hello,

 

I am trying to add a new schema + table to the blackboard database that is used inside my module. To do this i use SimpleDAO and i make a custom DAO class (AssessmentDAO) and an class (Assessment) corresponding to my schema table.

I am using Beans to get hold of the DAO:

ApplicationContext context = new ClassPathXmlApplicationContext("Beans.xml");           AssessmentDAO ado = (AssessmentDAO) context.getBean("assessDAO");

 

Schema:

<schema name="ntnu_assessment">
<table name="ntnu_assessment_test">
  <column name="pk1" data-type="int" nullable="false" comment="Surrogate primary key" />
  <column name="name" data-type="nvarchar(256)" nullable="false" />
  <column name="instructions" data-type="nvarchar(256)" nullable="true" />
  <column name="nr_reviews" data-type="int" nullable="false" comment="Number of people reviewing the assessemnt" />
  </table>
</schema>

 

The issue i get is that when i try to save my Assessment class using my AssessmentDAO i get the error "Could not perform database operation. An unknown error has occurred." The error log from the bb-sqlerror-log says this:

 

INSERT INTO ntnu_assessment_test ( name,value,nr_reviews,pk1 ) VALUES ( ,,,nextval('ntnu_assessment_test_seq') ) failed. - org.postgresql.util.PSQLException: ERROR: relation "ntnu_assessment_test_seq" does not exist

 

The current module is not using spring (i tried using spring but it did not seem to change anything, but i am no spring expert so i could have missed something).

The AssessmentDAO and Assessment class are near identical to working examples that uses the simpleDAO.

I have looked at the Schema example and other working DAO examples on github, i just cannot figure out what my module is missing.

 

To me it seems like the schema / table is not created in the blackboard database at all, so when the DAO runs "getDAOSupport().persist(newAssessment);" it tries to insert into a non existing schema/table, but i am no database expert so i hope that someone has had this issue before and could give be a hint.

ApplicationContext context = new ClassPathXmlApplicationContext("Beans.xml"); AssessmentDAO ado = (AssessmentDAO) context.getBean("assessDAO");

Outcomes