-->
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.  [ 4 posts ] 
Author Message
 Post subject: Problem updating an object
PostPosted: Wed Sep 01, 2010 10:59 pm 
Newbie

Joined: Mon Mar 22, 2010 6:57 am
Posts: 6
I am getting the unable to resolve property: username

I can't figure it out please help.

Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
      "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping schema="jrnl">
    <class name="com.philip.journal.core.bean.User" table="USER" schema="jrnl">
        <meta attribute="class-description">
            Represents a user of the Journal Application.
        </meta>

        <id name="username" type="string" length="16" access="field">
            <generator class="assigned" />
        </id>

        <property name="password" column="PASSWORD" type="string" not-null="false" length="128" />
        <property name="checksum" column="CHECKSUM" type="string" not-null="false" length="128" />

        <many-to-one class="com.philip.journal.core.bean.User" fetch="select" name="creator" column="CREATE_ID"
            property-ref="username" not-found="ignore" />
        <many-to-one class="com.philip.journal.core.bean.User" fetch="select" name="updater" column="UPDATE_ID"
            property-ref="username" not-found="ignore" />

        <property name="createDate" type="date">
            <column name="CREATE_DATE" length="13" not-null="false" />
        </property>
        <property name="createTime" type="time">
            <column name="CREATE_TIME" length="21" not-null="false" />
        </property>
        <property name="updateDate" type="date">
            <column name="UPDATE_DATE" length="13" not-null="false" />
        </property>
        <property name="updateTime" type="time">
            <column name="UPDATE_TIME" length="21" not-null="false" />
        </property>

        <filter name="patchFilter" condition="1=1" />
    </class>

    <query name="user.userByUsername">
        from User as user
        where user.username = :username
    </query>
    <filter-def name="patchFilter" />
</hibernate-mapping>


My java bean
Code:
package com.philip.journal.core.bean;

import com.philip.journal.core.exception.JournalRuntimeException;

/**
* Represents a user of the Journal Application.
*
* This bean is tied with spring hibernate. Will disallow setting the username from the client code.
*/
public class User extends AuditableBean {

    private String username;
    private String password;
    private String checksum;

    public User() {
    }

    public User(String username) {
        this.username = username;
    }
    public User(String username, String password, String checksum) {
        this.username = username;
        this.password = password;
        this.checksum = checksum;
    }

    public String getUsername() {
        return this.username;
    }

    /**
     * @param username
     * @exception JournalRuntimeException
     *                - this should never be set by client.
     */
    public void setUsername(String username) {
        this.username = username;
        /*
         * if (Thread.currentThread().getStackTrace()[6].getClassName().indexOf(
         * "org.hibernate.property.BasicPropertyAccessor$BasicSetter") > -1) { this.username = username; } else { throw
         * new JournalRuntimeException("Illegal access to protected object", null); }
         */}

    public String getPassword() {
        return this.password;
    }

    public void setPassword(String password) {
        this.password = password;
    }
    public String getChecksum() {
        return this.checksum;
    }

    public void setChecksum(String checksum) {
        this.checksum = checksum;
    }

    @Override
    public String getPrimaryKeyField() {
        return "username";
    }
}



Top
 Profile  
 
 Post subject: Re: Problem updating an object
PostPosted: Wed Sep 01, 2010 11:33 pm 
Newbie

Joined: Mon Mar 22, 2010 6:57 am
Posts: 6
Updating the jar file to hibernate v 3.5.5, I got a null pointer exception instead.


Top
 Profile  
 
 Post subject: Re: Problem updating an object [SOLVED]
PostPosted: Thu Sep 02, 2010 1:44 am 
Newbie

Joined: Mon Mar 22, 2010 6:57 am
Posts: 6
id mapping needs this:

<property name="username" column="username" type="string" not-null="true" length="16" insert="false" update="false" />


Top
 Profile  
 
 Post subject: Re: Problem updating an object
PostPosted: Thu Sep 02, 2010 1:53 am 
Regular
Regular

Joined: Fri Aug 06, 2010 1:49 am
Posts: 102
Location: shynate26@gmail.com
Hi thedatawarehouse,

Is it possible to change the database design assigning a identifier value as primary key. Its difficult having a string as primary key. Also hibernate looks for the identifier property, you can map identifier to the column username.

_________________

Cheers!
Shynate
mailto:shynate26@gmail.com
www.CSSCORP.com


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