All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.xlrit.gears.common.test_domain.Author Maven / Gradle / Ivy

There is a newer version: 1.17.5
Show newest version
package com.xlrit.gears.common.test_domain;

import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

import com.xlrit.gears.base.meta.*;
import com.xlrit.gears.base.model.Identifiable;
import jakarta.persistence.*;

import jakarta.persistence.Id;
import org.hibernate.Hibernate;

import lombok.*;

@EntityType(typeName = "AUTHOR", collectionName = "AUTHORS")
@Attributes({ "firstName", "lastName", "born", "isMale", "books" })
@Entity @Table(name="AUTHOR")
@Getter @Setter
@NoArgsConstructor
public class Author implements Identifiable {
	@Id @Getter
	private String id;

	@Column(name="FIRST_NAME_", nullable=false)
	@Attribute(formalName = "first_name", label = "First name", type = DataType.TEXT)
	private String firstName;

	@Column(name="LAST_NAME_", nullable=false)
	@Attribute(formalName = "last_name", label = "Last name", type = DataType.TEXT)
	private String lastName;

	@Column(name="BORN_", nullable=true)
	@Attribute(formalName = "born", label = "Born", type = DataType.DATE)
	private LocalDate born;

	@Column(name="IS_MALE_")
	@Attribute(formalName = "is_male", label = "Is male", type = DataType.BOOLEAN)
	private Boolean isMale;

	@OneToMany(mappedBy = "author")
	@Attribute(formalName = "BOOKS", label = "Books", type = DataType.ENTITY)
	private List books = new ArrayList<>();

	public Author(String id) {
		this.id = id;
	}

	@Override
	@Displayed
	public String toString() {
		return "Author[" +
			"id=" + id +
			", firstName='" + firstName + "'" +
			", lastName='" + lastName + "'" +
			']';
	}

	@Override
	public boolean equals(Object o) {
		if (this == o) return true;
		if (o == null || Hibernate.getClass(this) != Hibernate.getClass(o)) return false;
		Author author = (Author) o;
		return id != null && Objects.equals(id, author.id);
	}

	@Override
	public int hashCode() {
		return getClass().hashCode();
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy