jpa hibernate dodanie kolumny

0

Chciałbym dodać do tabali kolejne pole.
Musi spełniać warunki, że wiele systemów może być zainstalowanych na jednym komputerze.
Dla przykładu rozptruje przypadek, że na jednym komputerze może być zainstalowany windows lub linux lub oba systemy.

Mam encje:

@Entity
@Table(name = "computer"){

   
@Id
 var id: String? = null
@NotNull
var name: String? = null

@OneToMany
@OneToMany(cascade = [CascadeType.ALL], fetch = FetchType.LAZY)
 var systemType: SystemType?  = null

}

oraz encja CategoryType:

 @Entity
 @Table(name = "system_type")
 class SystemType {
 
@Id
var id: Long? = null
var windows: String? = null
var linux: String? = null
}

Jak uniknąć duplikacji w tabli Category Type? Chcialbym miec tylko 1-windows 2-linux. Czy to co napisałem jest poprawne?

1

A nie lepiej żeby żeby SystemType był enumem i był jako pole enumowe w encji Computer?

0

zamiast pól windows i linux zrób jedno pole "systemName" i już.

edit:
albo nawet lepiej enum tak jak napisał @Pinek - nie zauważyłem:)

1 użytkowników online, w tym zalogowanych: 0, gości: 1