/*
* #%L
* GarethHealy :: JBoss Fuse Examples :: Database Playground :: Hibernate
* %%
* Copyright (C) 2013 - 2017 Gareth Healy
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
package com.garethahealy.databaseplayground.database.model.entities;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import org.apache.commons.lang3.builder.ToStringBuilder;
@Entity
@Table(name = "beers")
@NamedQueries(@NamedQuery(name = Beer.SELECT_ALL_QUERY, query = "SELECT b FROM Beer b"))
public class Beer implements Serializable {
public static final String SELECT_ALL_QUERY = "Beer.SelectAll";
private static final long serialVersionUID = -5958885654581897644L;
private Integer id;
private String name;
public Beer() {
}
public Beer(Integer id, String name) {
this.id = id;
this.name = name;
}
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "id", unique = true, nullable = false)
public Integer getId() {
return this.id;
}
public void setId(Integer id) {
this.id = id;
}
@Column(name = "name")
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@Override
public String toString() {
return new ToStringBuilder(this)
.append("id", id)
.append("name", name)
.toString();
}
}