spring - EL1007E: Property or field 'classes' cannot be found on null - while trying to display name of classes in html -


i trying data multiple tables in spring data jpa.

user.java

@entity @table(name = "user") public class user{      @id     @generatedvalue(strategy = generationtype.table)     private long id;       private string username;      private string password;     //getters , setters generated      @manytomany(fetch = fetchtype.lazy, cascade = { cascadetype.merge, cascadetype.persist })     private list<classes> classes; 

classes.java

@entity public class classes {      @id     @generatedvalue(strategy = generationtype.table)     private long id;      private string name;      @lob     private string description;      @manytomany(mappedby = "classes", fetch = fetchtype.eager, cascade = { cascadetype.merge, cascadetype.persist })     private list<user> user; 

these entities generate table named 'user_classes' , fields following classes_id , user_id

i trying display name of classes belong particular user. have models designed shown above trying this

<tr th:each="classes : ${user.classes}">     <td th:text="${classes.name}"></td> </tr> 

my table in database looks this

database table

so class , user exist.

but facing error

el1007e: property or field 'classes' cannot found on null 

i not sure doing wrong?

mistake in spelling. have passed user object thymeleaf view as

<tbody th:each="users : ${users}"> 

and trying reach as

<tr th:each="classes : ${user.classes}">     <td th:text="${classes.name}"></td> </tr>  

where part ${user.classes} didn't work. when wrote user object users or ${users.classes} worked!


Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -