Note that there are some explanatory texts on larger screens.

plurals
  1. POModel instance being created but all attributes stay as null. Play Framework 1.2.7
    primarykey
    data
    text
    <p>I have a create page to create Courses. I can create courses but all their attributes are null except for the automatically generate attribute <code>id</code>. Here is my Model</p> <pre><code>public class Course extends Model { public String CourseName; public String CourseCode; @Lob public String CourseDescription; @ManyToOne public Department department; @OneToMany public List&lt;Session&gt; sessions; public Course(String CourseName, String CourseCode, String CourseDescription, Department department){ this.CourseName = CourseName; this.CourseCode = CourseCode; this.CourseDescription = CourseDescription; this.department = department; } </code></pre> <p>Here is the form</p> <pre><code> #{form @Courses.save(), id:'createUser'} &lt;div&gt; Course Name: &lt;input type="text" name="courseName" /&gt; &lt;/div&gt; &lt;div&gt; Course Code: &lt;input type="text" name="courseCode" /&gt; &lt;/div&gt; &lt;div&gt; Course Description: &lt;textarea name="courseDescription" form="createUser"&gt;&lt;/textarea&gt; &lt;/div&gt; &lt;div&gt; Department Id:&lt;input type = "text" name = "Dept_Id" /&gt; &lt;/div&gt; &lt;div&gt; &lt;input type="submit" value="Create Course" /&gt; &lt;/div&gt; #{/form} </code></pre> <p>And here is my controller method <code>save()</code></p> <pre><code> public static void save(String CourseName, String CourseCode, String CourseDescription, Long Dept_Id){ Department department = Department.findById(Dept_Id); Course course = new Course(CourseName, CourseCode, CourseDescription, department); course.save(); department.addCourse(course); department.save(); index(); } </code></pre> <p>In my debug console I get this SQL statement <code>insert into Course (CourseCode, CourseDescription, CourseName, department_id, id) values (?, ?, ?, ?, ?)</code> which looks fine to me.</p> <p>Edit 1:::</p> <p>I renamed the attributes to lower case, checked if attribute names were a match and then tried to create a new course. No Luck. Here is the screenshot of the course table</p> <p><img src="https://i.stack.imgur.com/3PC1G.png" alt="Screenshot of the Course Table"></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload