Binding child object on submit spring mvc

后端 未结 1 1987
無奈伤痛
無奈伤痛 2021-01-24 15:22

I\'m newbie in Java so this question looks so simple. I have a model like:

@Entity(name=\"website\")
public class Website {
@Id
@GeneratedValue(strategy=Generati         


        
相关标签:
1条回答
  • 2021-01-24 15:56

    simply change path in <form:select> tag from publisher to publisher.publisherId

    Some more things from my side:

    1. You don't need to use @Column(name="websiteId", nullable=false, unique=true)

      • Since You have column name in database same as field name in Entity class
      • Since it is Annotated with @Id it will never null and by default uniqe
    2. You don't need to use @JoinColumn at both side, at @OneToMany side use mappedBy attribute e.g. @OneToMany(mappedBy="publisher")

    0 讨论(0)
提交回复
热议问题