001package ball.game.crossword.entity; 002/*- 003 * ########################################################################## 004 * Game Applications and Utilities 005 * %% 006 * Copyright (C) 2010 - 2022 Allen D. Ball 007 * %% 008 * Licensed under the Apache License, Version 2.0 (the "License"); 009 * you may not use this file except in compliance with the License. 010 * You may obtain a copy of the License at 011 * 012 * http://www.apache.org/licenses/LICENSE-2.0 013 * 014 * Unless required by applicable law or agreed to in writing, software 015 * distributed under the License is distributed on an "AS IS" BASIS, 016 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 017 * See the License for the specific language governing permissions and 018 * limitations under the License. 019 * ########################################################################## 020 */ 021import java.util.ArrayList; 022import java.util.List; 023import javax.persistence.Column; 024import javax.persistence.Entity; 025import javax.persistence.Id; 026import javax.persistence.IdClass; 027import javax.persistence.Lob; 028import javax.persistence.OneToMany; 029import javax.persistence.Table; 030import lombok.EqualsAndHashCode; 031import lombok.Getter; 032import lombok.NoArgsConstructor; 033import lombok.Setter; 034import lombok.ToString; 035 036import static javax.persistence.CascadeType.ALL; 037 038/** 039 * {@link Grid} {@link Entity}. 040 * 041 * {@bean.info} 042 * 043 * @author {@link.uri mailto:ball@hcf.dev Allen D. Ball} 044 */ 045@Entity 046@Table(catalog = "crossword", name = "grid") 047@IdClass(Grid.PK.class) 048@NoArgsConstructor @EqualsAndHashCode(callSuper = false) @ToString 049public class Grid extends AbstractEntity { 050 @Id @Column(nullable = false) 051 @Getter @Setter 052 private int height = -1; 053 054 @Id @Column(nullable = false) 055 @Getter @Setter 056 private int width = -1; 057 058 @Id @Column @Lob 059 @Getter @Setter 060 private String string = null; 061 062 @OneToMany(mappedBy = "grid", cascade = ALL) 063 @Getter @Setter 064 private List<Crossword> crosswords = new ArrayList<>(); 065 066 @NoArgsConstructor @EqualsAndHashCode(callSuper = false) @ToString 067 public static class PK { 068 @Getter @Setter private int height = -1; 069 @Getter @Setter private int width = -1; 070 @Getter @Setter private String string = null; 071 } 072}