-->
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.  [ 3 posts ] 
Author Message
 Post subject: me or Hibernate doing it wrong?
PostPosted: Wed Oct 29, 2003 3:01 pm 
Beginner
Beginner

Joined: Wed Oct 29, 2003 11:52 am
Posts: 37
Location: Gothenburg, Sweden
I have this mapping:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
  "-//Hibernate/Hibernate Mapping DTD 2.0//EN"
  "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
    <class name="se.barnvagnsfabriken.shop.beans.Order" table="Orders">
        <id name="id" column="id">
            <generator class="native"/>
        </id>
        <property name="payment" />
        <property name="delivery" />
        <property name="name" />
        <property name="address" />
        <property name="phone" />
        <property name="fax" />
        <property name="mobile" />
        <property name="eMailAddress" />
        <property name="submitted" />

        <!-- the order queue -->
        <many-to-one name="queue" class="se.barnvagnsfabriken.shop.beans.OrderQueue" />

        <!-- the order rows -->
        <set name="orderRows" lazy="true" inverse="true">
            <key column="order" />
            <one-to-many class="se.barnvagnsfabriken.shop.beans.OrderRow" />
        </set>

    </class>
</hibernate-mapping>


And an excerpt from se.barn...Order.java: (notice the double getter and setter methods)
Code:
    /**
     * Getter for property eMailAddress.
     *
     * @return Value of property eMailAddress.
     */
    public String getEMailAddress() {
        return this.eMailAddress;
    }
    public String geteMailAddress() {
        return getEMailAddress();
    }

    /**
     * Setter for property eMailAddress.
     *
     * @param eMailAddress New value of property eMailAddress.
     */
    public void setEMailAddress(String eMailAddress) {
        this.eMailAddress = eMailAddress;
    }
    public void seteMailAddress(String eMailAddress) {
        setEMailAddress(eMailAddress);
    }


If I remove [get|set]eMailAdress methods, Hibernate complaints that it can't find setter/getter methods for property eMailAddress. Is this me mistaking thinking the defualt getter/setter should be named with the e in upper case, like getEMailAddress?

Stack trace from exception thrown upon Configuration, with an Order class without geteMailAddress(), only getEMailAddress():
Code:
INFO: Mapping class: se.barnvagnsfabriken.shop.beans.Order -> Orders
2003-okt-29 19:52:33 net.sf.hibernate.cfg.Configuration add
ALLVARLIG: Could not compile the mapping document
net.sf.hibernate.PropertyNotFoundException: Could not find a getter for eMailAddress in class se.barnvagnsfabriken.shop.beans.Order
        at net.sf.hibernate.util.ReflectHelper.getGetter(ReflectHelper.java:206)
        at net.sf.hibernate.util.ReflectHelper.reflectedPropertyType(ReflectHelper.java:260)
        at net.sf.hibernate.mapping.Value.setTypeByReflection(Value.java:92)
        at net.sf.hibernate.cfg.Binder.propertiesFromXML(Binder.java:912)
        at net.sf.hibernate.cfg.Binder.bindRootClass(Binder.java:294)
        at net.sf.hibernate.cfg.Binder.bindRoot(Binder.java:1095)
        at net.sf.hibernate.cfg.Configuration.add(Configuration.java:230)
        at net.sf.hibernate.cfg.Configuration.addInputStream(Configuration.java:252)
        at net.sf.hibernate.cfg.Configuration.addResource(Configuration.java:273)
        at net.sf.hibernate.cfg.Configuration.configure(Configuration.java:838)
        at net.sf.hibernate.cfg.Configuration.configure(Configuration.java:792)
        at net.sf.hibernate.cfg.Configuration.configure(Configuration.java:732)
        at net.sf.hibernate.cfg.Configuration.configure(Configuration.java:719)
        at com.wsys.mwa.MasterServlet.startUp(MasterServlet.java:334)
        at com.wsys.mwa.MasterServlet.init(MasterServlet.java:68)
        at javax.servlet.GenericServlet.init(GenericServlet.java:256)
        at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:924)
        at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:813)
        at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3341)
        at org.apache.catalina.core.StandardContext.start(StandardContext.java:3534)
        at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1188)
        at org.apache.catalina.core.StandardHost.start(StandardHost.java:738)
        at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1188)
        at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:347)
        at org.apache.catalina.core.StandardService.start(StandardService.java:497)
        at org.apache.catalina.core.StandardServer.start(StandardServer.java:2189)
        at org.apache.catalina.startup.Catalina.start(Catalina.java:510)
        at org.apache.catalina.startup.Catalina.execute(Catalina.java:400)
        at org.apache.catalina.startup.Catalina.process(Catalina.java:180)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:324)
        at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:203)
rethrown as net.sf.hibernate.MappingException: Problem trying to set property type by reflection: Could not find a getter for eMailAddress in class se.barnvagnsfabriken.shop.beans.Order
        at net.sf.hibernate.mapping.Value.setTypeByReflection(Value.java:103)
        at net.sf.hibernate.cfg.Binder.propertiesFromXML(Binder.java:912)
        at net.sf.hibernate.cfg.Binder.bindRootClass(Binder.java:294)
        at net.sf.hibernate.cfg.Binder.bindRoot(Binder.java:1095)
        at net.sf.hibernate.cfg.Configuration.add(Configuration.java:230)
        at net.sf.hibernate.cfg.Configuration.addInputStream(Configuration.java:252)
        at net.sf.hibernate.cfg.Configuration.addResource(Configuration.java:273)
        at net.sf.hibernate.cfg.Configuration.configure(Configuration.java:838)
        at net.sf.hibernate.cfg.Configuration.configure(Configuration.java:792)
        at net.sf.hibernate.cfg.Configuration.configure(Configuration.java:732)
        at net.sf.hibernate.cfg.Configuration.configure(Configuration.java:719)
        at com.wsys.mwa.MasterServlet.startUp(MasterServlet.java:334)
        at com.wsys.mwa.MasterServlet.init(MasterServlet.java:68)
        at javax.servlet.GenericServlet.init(GenericServlet.java:256)
        at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:924)
        at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:813)
        at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3341)
        at org.apache.catalina.core.StandardContext.start(StandardContext.java:3534)
        at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1188)
        at org.apache.catalina.core.StandardHost.start(StandardHost.java:738)
        at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1188)
        at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:347)
        at org.apache.catalina.core.StandardService.start(StandardService.java:497)
        at org.apache.catalina.core.StandardServer.start(StandardServer.java:2189)
        at org.apache.catalina.startup.Catalina.start(Catalina.java:510)
        at org.apache.catalina.startup.Catalina.execute(Catalina.java:400)
        at org.apache.catalina.startup.Catalina.process(Catalina.java:180)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:324)
        at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:203)
Caused by: net.sf.hibernate.PropertyNotFoundException: Could not find a getter for eMailAddress in class se.barnvagnsfabriken.shop.beans.Order
        at net.sf.hibernate.util.ReflectHelper.getGetter(ReflectHelper.java:206)
        at net.sf.hibernate.util.ReflectHelper.reflectedPropertyType(ReflectHelper.java:260)
        at net.sf.hibernate.mapping.Value.setTypeByReflection(Value.java:92)
        ... 31 more


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 29, 2003 3:09 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
Neither, its actually the JavaBean specs. Well, maybe you :)

I have property email and getEmail()/setEmail().


Top
 Profile  
 
 Post subject: Capitalized property name
PostPosted: Wed Oct 29, 2003 3:24 pm 
Beginner
Beginner

Joined: Wed Oct 29, 2003 11:52 am
Posts: 37
Location: Gothenburg, Sweden
Good. I'll just have to read up on the specs again. It might even say why there's an exception to the "rule of thumb"; capitalize the property name.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.