Commit b80cc313 authored by michael.simon's avatar michael.simon
Browse files

add entity classes

parent 7db728cc
/*******************************************************************************
* Copyright (c) 2014 Michael Simon.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Public License v3.0
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/gpl.html
*
* Contributors:
* Michael Simon - initial
******************************************************************************/
package edu.kit.scc.webreg.dao;
import edu.kit.scc.webreg.entity.ScriptEntity;
public interface ScriptDao extends BaseDao<ScriptEntity, Long> {
ScriptEntity findByName(String name);
}
/*******************************************************************************
* Copyright (c) 2014 Michael Simon.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Public License v3.0
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/gpl.html
*
* Contributors:
* Michael Simon - initial
******************************************************************************/
package edu.kit.scc.webreg.dao.jpa;
import javax.enterprise.context.ApplicationScoped;
import javax.inject.Named;
import javax.persistence.NoResultException;
import edu.kit.scc.webreg.dao.ScriptDao;
import edu.kit.scc.webreg.entity.ScriptEntity;
@Named
@ApplicationScoped
public class JpaScriptlDao extends JpaBaseDao<ScriptEntity, Long> implements ScriptDao {
@Override
public ScriptEntity findByName(String name) {
try {
return (ScriptEntity) em.createQuery("select e from ScriptEntity e where e.name = :name")
.setParameter("name", name).getSingleResult();
} catch (NoResultException e) {
return null;
}
}
@Override
public Class<ScriptEntity> getEntityClass() {
return ScriptEntity.class;
}
}
/*******************************************************************************
* Copyright (c) 2014 Michael Simon.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Public License v3.0
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/gpl.html
*
* Contributors:
* Michael Simon - initial
******************************************************************************/
package edu.kit.scc.webreg.entity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Lob;
import javax.persistence.Table;
import org.hibernate.annotations.Type;
@Entity(name = "ScriptEntity")
@Table(name = "script")
public class ScriptEntity extends AbstractBaseEntity {
private static final long serialVersionUID = 1L;
@Column(name = "script_text")
@Lob
@Type(type = "org.hibernate.type.TextType")
private String script;
@Column(name = "rule_type", length = 32)
private String scriptType;
@Column(name = "name", length = 128)
private String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getScript() {
return script;
}
public void setScript(String script) {
this.script = script;
}
}
package edu.kit.scc.webreg.entity;
import javax.annotation.Generated;
import javax.persistence.metamodel.SingularAttribute;
import javax.persistence.metamodel.StaticMetamodel;
@Generated(value = "org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor")
@StaticMetamodel(ScriptEntity.class)
public abstract class ScriptEntity_ extends edu.kit.scc.webreg.entity.AbstractBaseEntity_ {
public static volatile SingularAttribute<ScriptEntity, String> script;
public static volatile SingularAttribute<ScriptEntity, String> scriptType;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment