-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Hibernate: Unable to locate persister: java.math.BigDecimal
PostPosted: Tue Aug 16, 2016 1:32 am 
Newbie

Joined: Tue Aug 16, 2016 1:27 am
Posts: 2
I am trying to combine guice, jpa and hibernate. The initialization of hibernate looks good, until i try to access a mapped class trough a DAO. I read a lot of similar help requests, but my problem is (for now) not a "custom-class" (at least I dont think so).

All together nothing special. I got my persistence.xml which defines my classes and a basic (persist, findById, remove) DAO for one of that classes.

Code:
    public abstract class AbstractDao<E, K> implements Dao<E, K> {
   
        @Inject
        private EntityManager  manager;
        private final Class<E> entityClass;
   
        @SuppressWarnings("unchecked")
        public AbstractDao() {
            final ParameterizedType genericSuperclass = (ParameterizedType) this.getClass().getGenericSuperclass();
            this.entityClass = (Class<E>) genericSuperclass.getActualTypeArguments()[1];
        }
   
        @Override
        public void persist(final E entity) {
            this.manager.persist(entity);
        }
   
        @Override
        public void remove(final E entity) {
            this.manager.remove(entity);
        }
   
        @Override
        public E findById(final K id) {
            return this.manager.find(this.entityClass, id);
        }
    }


The used DAO-Class. Nothing in it except the type definition for the generics:
Code:
    public class LayerDao extends AbstractDao<Layer, Long> {
   
    }



If I try to access the database with that DAO like

Code:
    final LayerDao dao = this.layerDaoProvider.get();
    final Layer layer = dao.findById(386L); //Tried with BigDecimal, Long


I get the following error (I get the exact same error with *java.lang.Long*):

Code:
    Caused by: org.hibernate.UnknownEntityTypeException: Unable to locate persister: java.math.BigDecimal
       at org.hibernate.metamodel.internal.MetamodelImpl.locateEntityPersister(MetamodelImpl.java:637) ~[hibernate-core-5.2.2.Final.jar:5.2.2.Final]
       at org.hibernate.internal.SessionImpl.locateEntityPersister(SessionImpl.java:2909) ~[hibernate-core-5.2.2.Final.jar:5.2.2.Final]
       at org.hibernate.internal.SessionImpl.access$1800(SessionImpl.java:203) ~[hibernate-core-5.2.2.Final.jar:5.2.2.Final]
       at org.hibernate.internal.SessionImpl$IdentifierLoadAccessImpl.<init>(SessionImpl.java:2660) ~[hibernate-core-5.2.2.Final.jar:5.2.2.Final]
       at org.hibernate.internal.SessionImpl$IdentifierLoadAccessImpl.<init>(SessionImpl.java:2646) ~[hibernate-core-5.2.2.Final.jar:5.2.2.Final]
       at org.hibernate.internal.SessionImpl.byId(SessionImpl.java:1181) ~[hibernate-core-5.2.2.Final.jar:5.2.2.Final]
       at org.hibernate.internal.SessionImpl.find(SessionImpl.java:3357) ~[hibernate-core-5.2.2.Final.jar:5.2.2.Final]
       at org.hibernate.internal.SessionImpl.find(SessionImpl.java:3332) ~[hibernate-core-5.2.2.Final.jar:5.2.2.Final]
    [..]


I did not expect to have problems with some java-core classes.

This are all my configured gradle dependencies:

Code:
compile group: 'org.slf4j', name: 'slf4j-api', version: '1.7.21'   
// https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-slf4j-impl
compile group: 'org.apache.logging.log4j', name: 'log4j-slf4j-impl', version: '2.6.2'
// https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-core
compile group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.6.2'
// https://mvnrepository.com/artifact/com.google.inject/guice
compile group: 'com.google.inject', name: 'guice', version: '4.1.0'
// https://mvnrepository.com/artifact/com.google.inject.extensions/guice-persist
compile group: 'com.google.inject.extensions', name: 'guice-persist', version: '4.1.0'
// https://mvnrepository.com/artifact/com.cathive.fx/fx-guice
compile group: 'com.cathive.fx', name: 'fx-guice', version: '8.0.0'
// https://mvnrepository.com/artifact/org.hibernate/hibernate-core
compile group: 'org.hibernate', name: 'hibernate-core', version: '5.2+'


The mapped class i try to access. It is automatically created with Eclipse (latest JEE Edition):

Code:
    import java.io.Serializable;
    import javax.persistence.*;
    import java.math.BigDecimal;
    import java.util.Date;
   
   
    /**
     * The persistent class for the T_M_LAYER_NEU database table.
     *
     */
    @Entity
    @Table(name="T_M_LAYER_NEU")
    @NamedQuery(name="Layer.findAll", query="SELECT l FROM Layer l")
    public class Layer implements Serializable {
       private static final long serialVersionUID = 1L;
   
       @Id
       @SequenceGenerator(name="T_M_LAYER_NEU_ID_GENERATOR", sequenceName="FIG_SYS_SEQ")
       @GeneratedValue(strategy=GenerationType.SEQUENCE, generator="T_M_LAYER_NEU_ID_GENERATOR")
       @Column(unique=true, nullable=false, precision=38)
       private long id;
   
       @Column(nullable=false, precision=1)
       private BigDecimal component;
   
       @Column(name="DISPLAY_ORDER", nullable=false, precision=3)
       private BigDecimal displayOrder;
   
       @Column(nullable=false, precision=1)
       private BigDecimal exklusiv;
   
       @Column(name="GEOMETRIETYP_ID_FK", precision=2)
       private BigDecimal geometrietypIdFk;
   
       @Temporal(TemporalType.DATE)
       @Column(name="GUELTIG_BIS", nullable=false)
       private Date gueltigBis;
   
       @Temporal(TemporalType.DATE)
       @Column(name="GUELTIG_VON", nullable=false)
       private Date gueltigVon;
   
       @Column(nullable=false, precision=1)
       private BigDecimal isactive;
   
       @Column(nullable=false, precision=1)
       private BigDecimal iskulisse;
   
       @Column(nullable=false, precision=1)
       private BigDecimal isoverview;
   
       @Column(name="LAYERTYP_ID_FK", nullable=false, precision=2)
       private BigDecimal layertypIdFk;
   
       @Column(nullable=false, length=80)
       private String name;
   
       @Column(name="R_O", nullable=false, precision=1)
       private BigDecimal rO;
   
       @Column(name="SOURCE_ID", precision=38)
       private BigDecimal sourceId;
   
       @Column(name="\"SYSTEM\"", nullable=false, precision=1)
       private BigDecimal system;
   
       @Column(name="USE_COMPLETECACHE", nullable=false, precision=1)
       private BigDecimal useCompletecache;
   
       @Column(name="XML_DEF", length=100)
       private String xmlDef;
   
       //bi-directional many-to-one association to Label
       @ManyToOne
       @JoinColumn(name="LABEL_ID_FK")
       private Label label;
   
       //bi-directional many-to-one association to Symbol
       @ManyToOne
       @JoinColumn(name="SYM_ID_FK")
       private Symbol symbol;
   
       //bi-directional many-to-one association to Tabellen
       @ManyToOne
       @JoinColumn(name="LAYERDEF_ID_FK")
       private Tabellen table;
   
       public Layer() {
       }
   
       public long getId() {
          return this.id;
       }
   
       public void setId(long id) {
          this.id = id;
       }
   
       public BigDecimal getComponent() {
          return this.component;
       }
   
       public void setComponent(BigDecimal component) {
          this.component = component;
       }
   
       public BigDecimal getDisplayOrder() {
          return this.displayOrder;
       }
   
       public void setDisplayOrder(BigDecimal displayOrder) {
          this.displayOrder = displayOrder;
       }
   
       public BigDecimal getExklusiv() {
          return this.exklusiv;
       }
   
       public void setExklusiv(BigDecimal exklusiv) {
          this.exklusiv = exklusiv;
       }
   
       public BigDecimal getGeometrietypIdFk() {
          return this.geometrietypIdFk;
       }
   
       public void setGeometrietypIdFk(BigDecimal geometrietypIdFk) {
          this.geometrietypIdFk = geometrietypIdFk;
       }
   
       public Date getGueltigBis() {
          return this.gueltigBis;
       }
   
       public void setGueltigBis(Date gueltigBis) {
          this.gueltigBis = gueltigBis;
       }
   
       public Date getGueltigVon() {
          return this.gueltigVon;
       }
   
       public void setGueltigVon(Date gueltigVon) {
          this.gueltigVon = gueltigVon;
       }
   
       public BigDecimal getIsactive() {
          return this.isactive;
       }
   
       public void setIsactive(BigDecimal isactive) {
          this.isactive = isactive;
       }
   
       public BigDecimal getIskulisse() {
          return this.iskulisse;
       }
   
       public void setIskulisse(BigDecimal iskulisse) {
          this.iskulisse = iskulisse;
       }
   
       public BigDecimal getIsoverview() {
          return this.isoverview;
       }
   
       public void setIsoverview(BigDecimal isoverview) {
          this.isoverview = isoverview;
       }
   
       public BigDecimal getLayertypIdFk() {
          return this.layertypIdFk;
       }
   
       public void setLayertypIdFk(BigDecimal layertypIdFk) {
          this.layertypIdFk = layertypIdFk;
       }
   
       public String getName() {
          return this.name;
       }
   
       public void setName(String name) {
          this.name = name;
       }
   
       public BigDecimal getRO() {
          return this.rO;
       }
   
       public void setRO(BigDecimal rO) {
          this.rO = rO;
       }
   
       public BigDecimal getSourceId() {
          return this.sourceId;
       }
   
       public void setSourceId(BigDecimal sourceId) {
          this.sourceId = sourceId;
       }
   
       public BigDecimal getSystem() {
          return this.system;
       }
   
       public void setSystem(BigDecimal system) {
          this.system = system;
       }
   
       public BigDecimal getUseCompletecache() {
          return this.useCompletecache;
       }
   
       public void setUseCompletecache(BigDecimal useCompletecache) {
          this.useCompletecache = useCompletecache;
       }
   
       public String getXmlDef() {
          return this.xmlDef;
       }
   
       public void setXmlDef(String xmlDef) {
          this.xmlDef = xmlDef;
       }
   
       public Label getLabel() {
          return this.label;
       }
   
       public void setLabel(Label label) {
          this.label = label;
       }
   
       public Symbol getSymbol() {
          return this.symbol;
       }
   
       public void setSymbol(Symbol symbol) {
          this.symbol = symbol;
       }
   
       public Tabellen getTable() {
          return this.table;
       }
   
       public void setTable(Tabellen table) {
          this.table = table;
       }
    }


What am I missing? Do you need any more information to help me?


Top
 Profile  
 
 Post subject: Re: Hibernate: Unable to locate persister: java.math.BigDecimal
PostPosted: Mon Aug 29, 2016 3:24 am 
Newbie

Joined: Tue Aug 16, 2016 1:27 am
Posts: 2
Since it needed two(!) weeks to get approved in this forums i already managed to find the mistake.

This is a link where i posted the solution:
stackoverflow question/answer


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.