Commit 6fec5f23 by Jan Hrabal

sql

parent ac125b9b
package com.jh.boot.document; package com.jh.boot.document;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import com.jh.boot.jpa.AbstractIdEntity; import com.jh.boot.jpa.AbstractIdEntity;
@Entity
@Table(name = "LEGAL_DOCUMENT")
public class LegalDocument extends AbstractIdEntity { public class LegalDocument extends AbstractIdEntity {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@Column(name = "CODE")
private String code; private String code;
@Column(name = "LOCALE")
private String locale; private String locale;
private String text; @Column(name = "CONTENT")
private String content;
public LegalDocument() { public LegalDocument() {
} }
...@@ -19,7 +28,7 @@ public class LegalDocument extends AbstractIdEntity { ...@@ -19,7 +28,7 @@ public class LegalDocument extends AbstractIdEntity {
super(); super();
this.code = code; this.code = code;
this.locale = locale; this.locale = locale;
this.text = text; this.content = text;
} }
public String getCode() { public String getCode() {
...@@ -38,12 +47,12 @@ public class LegalDocument extends AbstractIdEntity { ...@@ -38,12 +47,12 @@ public class LegalDocument extends AbstractIdEntity {
this.locale = locale; this.locale = locale;
} }
public String getText() { public String getContent() {
return text; return content;
} }
public void setText(String text) { public void setContent(String text) {
this.text = text; this.content = text;
} }
} }
...@@ -21,8 +21,8 @@ public class LegalDocumentRepository extends AbstractHibernateRepository { ...@@ -21,8 +21,8 @@ public class LegalDocumentRepository extends AbstractHibernateRepository {
locale = locale.replace("-", "_"); locale = locale.replace("-", "_");
Query q = entityManager.createQuery("select ld from LegalDocument ld where lower(ld.code) = :code and lower(ld.locale) = :locale"); Query q = entityManager.createQuery("select ld from LegalDocument ld where lower(ld.code) = :code and lower(ld.locale) = :locale");
q.setParameter("code", locale.trim().toLowerCase()); q.setParameter("code", code.toLowerCase());
q.setParameter("locale", locale.trim().toLowerCase()); q.setParameter("locale", locale.toLowerCase());
LegalDocument ld = singleResult(q); LegalDocument ld = singleResult(q);
if (ld == null) { if (ld == null) {
...@@ -33,7 +33,7 @@ public class LegalDocumentRepository extends AbstractHibernateRepository { ...@@ -33,7 +33,7 @@ public class LegalDocumentRepository extends AbstractHibernateRepository {
} }
} }
return null; return ld;
} }
......
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