0

Hello how can I put "unassigned" value on a table that has a join with cascade on delete with an other table instead of leaving it in null in an entity?

@OneToMany(fetch = FetchType.LAZY,cascade= CascadeType.ALL)
    @JoinColumn(name = "departmentName")
juanpalomo
  • 63
  • 1
  • 8
  • What do you mean by "unassigned"? –  Nov 04 '18 at 11:50
  • Which is the type of the field? – Gilberto T. Nov 04 '18 at 12:14
  • The type of the field is string and instead of blank i want to put the string "unassigned" – juanpalomo Nov 04 '18 at 13:27
  • 2
    The type of the field can't possibly be string. It's a OneToMany, so it refers to Many entities. I have no idea of what you're asking. You need to seriously elaborate. I just have the feeling that you're mixing presentation considerations (displaying some message when a condition is true), with persistence considerations. – JB Nizet Nov 04 '18 at 13:41
  • there are two tables for example users with a column department_name and an other table department if I delete a department I want all users that have that department_name(foreign key in users) to instead of null put "unassigned" is that posible? – juanpalomo Nov 04 '18 at 14:46
  • Why do you need to put "unassigned" instead of null?? (What are you expecting to resolve with this?) I'm asking you because we can find may be a better approach... by the way, if the departament name column at User is really a FK, and you database checks integrity, you will need a "unassigned" department... – Carlitos Way Nov 04 '18 at 16:34

0 Answers0