Skip to content

Commit

Permalink
Keep @vsalaman happy by using annotations
Browse files Browse the repository at this point in the history
We'll eventually get rid of .hbm.xmls (although it will take some time).
  • Loading branch information
ar committed Aug 21, 2016
1 parent db5aee2 commit 23e2a18
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 50 deletions.
13 changes: 13 additions & 0 deletions modules/sysconfig/src/main/java/org/jpos/ee/SysConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,25 @@
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder;

import javax.persistence.*;

@Entity
@Table(name = "sysconfig")
@SuppressWarnings("unused")
public class SysConfig extends Cloneable implements Serializable {
@Id
@Column(length=64)
private String id;

@Column(length=2048)
private String value;

@Column(length=64)
private String readPerm;

@Column(length=64)
private String writePerm;

public SysConfig(String id, String value, String readPerm, String writePerm) {
this.id = id;
this.value = value;
Expand Down
15 changes: 4 additions & 11 deletions modules/sysconfig/src/main/java/org/jpos/ee/SysConfigManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,9 @@

import java.util.List;
import java.util.Iterator;
import org.hibernate.Query;
import org.hibernate.query.Query;
import org.hibernate.Transaction;
import org.hibernate.HibernateException;
import org.hibernate.ObjectNotFoundException;
import org.hibernate.resource.transaction.spi.TransactionStatus;

@SuppressWarnings("unused")
Expand All @@ -50,11 +49,7 @@ public boolean hasProperty (String name) {
try {
if (prefix != null)
name = prefix + name;
SysConfig cfg = (SysConfig)
db.session().get (SysConfig.class, name);
return cfg != null;
} catch (ObjectNotFoundException e) {
// okay to happen
return db.session().get(SysConfig.class, name) != null;
} catch (HibernateException e) {
db.getLog().warn (e);
}
Expand All @@ -70,7 +65,7 @@ public String get (String name, String defaultValue) {
try {
if (prefix != null)
name = prefix + name;
SysConfig cfg = (SysConfig) db.session().get (SysConfig.class, name);
SysConfig cfg = db.session().get (SysConfig.class, name);
if (cfg != null)
return cfg.getValue();
} catch (HibernateException e) {
Expand Down Expand Up @@ -121,8 +116,6 @@ public SysConfig[] getAll () {
return values;
}



@SuppressWarnings("unchecked")
public Iterator<SysConfig> iterator() {
Query query;
Expand Down Expand Up @@ -152,7 +145,7 @@ public void put (String name, String value, String readPerm, String writePerm) {
tx = db.session().beginTransaction();
autoCommit = true;
}
cfg = (SysConfig) db.session().get (SysConfig.class, name);
cfg = db.session().get (SysConfig.class, name);
boolean saveIt = false;
if (cfg == null) {
cfg = new SysConfig ();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<!--
~ jPOS Project [http://jpos.org]
~ Copyright (C) 2000-2012 Alejandro P. Revilla
~ Copyright (C) 2000-2016 Alejandro P. Revilla
~
~ This program is free software: you can redistribute it and/or modify
~ it under the terms of the GNU Affero General Public License as
Expand All @@ -17,9 +17,7 @@
-->

<module name="sysconfig">

<mappings>
<mapping resource="org/jpos/ee/SysConfig.hbm.xml"/>
<mapping class="org.jpos.ee.SysConfig"/>
</mappings>

</module>
35 changes: 0 additions & 35 deletions modules/sysconfig/src/main/resources/org/jpos/ee/SysConfig.hbm.xml

This file was deleted.

0 comments on commit 23e2a18

Please sign in to comment.