Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Entity
- @Table(name = "ticket")
- @XmlRootElement
- public class Ticket implements Serializable {
- private static final long serialVersionUID = 1L;
- @Id
- @GeneratedValue(strategy = GenerationType.IDENTITY)
- @Basic(optional = false)
- @Column(name = "ticket_id")
- private Long ticketId;
- @Column(name = "description")
- private String description;
- @Column(name = "note")
- private String note;
- @ManyToOne(targetEntity=LoginInfo.class,cascade=CascadeType.ALL)
- private LoginInfo createdBy;
- @Entity
- @Table(name = "login_info")
- @XmlRootElement
- public class LoginInfo implements Serializable {
- private static final long serialVersionUID = 1L;
- @Id
- @GeneratedValue(strategy = GenerationType.IDENTITY)
- @Basic(optional = false)
- @Column(name = "login_info_id")
- private Long loginInfoId;
- @Column(name = "username")
- private String username;
- @Column(name = "pwd")
- private String pwd;
- @Column(name = "role")
- private String role = "user";
- @OneToMany(cascade=CascadeType.ALL, mappedBy="loginInfo1")
- private List<UserInfo> userInfoList;
- @OneToMany(cascade=CascadeType.MERGE, mappedBy="createdBy")
- private List<Ticket> createdByList;
- public Ticket create(Ticket t) {
- Ticket ticket = new Ticket();
- try{
- //LoginInfo login = findUser(t.getCreatedBy().getUsername());
- tx.begin();
- ticket.setDescription(t.getDescription());
- ticket.setNote(t.getNote());
- ticket.setDateCreated(new Date());
- ticket.setCreatedBy(t.getCreatedBy());
- em.persist(ticket);
- tx.commit();
- }catch(Exception e){
- e.toString();
- }
- return ticket;
- }
- Internal Exception: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException:
- Column 'pwd' cannot be null
- Error Code: 1048
- Call: INSERT INTO login_info (pwd, role, username) VALUES (?, ?, ?)
- bind => [3 parameters bound]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement