This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Little Book of Impediments (e-book only) and have Tom Perry on-line!
See this thread for details.
Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Error org.hibernate.PropertyNotFoundException: Could not find a getter

Srikanth Tasupalli
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to run an example to modify configuation-time metamodel of a class. I did not get how it works. I get the following error
org.hibernate.PropertyNotFoundException: Could not find a getter for motto

1. Does the persistent class need a property, getters and setters when modifying its Class Mapping ?
If so, whats the reason to dynamically modify...Can't it be done manually.

2. If I add the property motto and its methods as per the exception in persistent class, I get an error org.hibernate.MappingException: no node name for property: motto

Below is the code I am trying to run. Can you help me with the idea behind it.

Code to run:

Configuration cfg = new Configuration();

PrintWriter pw = response.getWriter();
pw.println("Entered Servlet");


PersistentClass UserMappng= cfg.getClassMapping


Column column = new Column();


SimpleValue value = new SimpleValue();

Property prop = new Property();


SessionFactory sf = cfg.buildSessionFactory();
ClassMetadata meta = sf.getClassMetadata(User.class);
String[] metaPropertyNames = meta.getPropertyNames();
Object[] propertyValues = meta
.getPropertyValues(User.class, EntityMode.POJO);

for (int i = 0; i < metaPropertyNames.length; i++) {

pw.println("----metaPropertyNames --- "+ metaPropertyNames[i]);
pw.println("----propertyValues --- "+propertyValues[i]);

System.out.println("----metaPropertyNames --- "+ metaPropertyNames[i]);
System.out.println("-----propertyValues --- "+propertyValues[i]);



Persistent Class
motto is the property to be added

package com.Cavatier.Classes;


public class User implements Serializable{

private Integer id;

private String username;
private String address;

// private String motto;
// public String getMotto() {
// return motto;
// }
// public void setMotto(String motto) {
// this.motto = motto;
// }

public User() {
// TODO Auto-generated constructor stub

public String getUsername() {
return username;

public void setUsername(String username) {
this.username = username;

public String getAddress() {
return address;

public void setAddress(String address) {
this.address = address;

public Integer getId() {
return id;

public void setId(Integer id) { = id;

/*public MonetaryAmount calcShippingCosts(Address fromLocation){




<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
<hibernate-mapping package="com.Cavatier.Classes">

<class name="User" table="USER">

<id name="id" column="USER_ID" type="long">
<generator class="native"></generator>
<property name="username" column="USERNAME" type="string"></property>
<property name="address" column="ADDRESS" type="string"></property>


  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic