-->
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: DOESN'T WORK
PostPosted: Tue Sep 16, 2003 4:30 am 
Beginner
Beginner

Joined: Mon Sep 15, 2003 9:10 am
Posts: 43
DOESN'T WORK :

After the generation made by hbm2java I need to add manually this code to my class :

private Long id; // the Hibernate identifier

public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}

If i don't, i avec a 503 error in my application for all my servlet !


--------------------------------------------


this is my simple mapping

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

<hibernate-mapping>

<class name="hibernate.src.Utilisateur" table="utilisateurs">
<id name="id" column="id" type="long">
<generator class="hilo"/>
</id>
<property name="login" type="java.lang.String" column="login" length="255"/>
<property name="mdp" type="java.lang.String" column="mdp" length="255"/>
</class>

</hibernate-mapping>

this is my java generated :

package hibernate.src;

import java.io.Serializable;
import org.apache.commons.lang.builder.ToStringBuilder;

/** @author Hibernate CodeGenerator */
public class Utilisateur implements Serializable {

/** nullable persistent field */
private String login;

/** nullable persistent field */
private String mdp;

/** full constructor */
public Utilisateur(java.lang.String login, java.lang.String mdp) {
this.login = login;
this.mdp = mdp;
}

/** default constructor */
public Utilisateur() {
}

public java.lang.String getLogin() {
return this.login;
}

public void setLogin(java.lang.String login) {
this.login = login;
}

public java.lang.String getMdp() {
return this.mdp;
}

public void setMdp(java.lang.String mdp) {
this.mdp = mdp;
}

public String toString() {
return new ToStringBuilder(this)
.toString();
}

}


Top
 Profile  
 
 Post subject: Re: DOESN'T WORK
PostPosted: Tue Sep 16, 2003 5:10 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
When I take your example and run it with the current version of hbm2java i get:

Code:
package hibernate.src;

import java.io.Serializable;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;

/** @author Hibernate CodeGenerator */
public class Utilisateur implements Serializable {

    /** identifier field */
    private java.lang.Long id;

    /** nullable persistent field */
    private java.lang.String login;

    /** nullable persistent field */
    private java.lang.String mdp;

    /** full constructor */
    public Utilisateur(java.lang.String login, java.lang.String mdp) {
        this.login = login;
        this.mdp = mdp;
    }

    /** default constructor */
    public Utilisateur() {
    }

    public java.lang.Long getId() {
        return this.id;
    }

    public void setId(java.lang.Long id) {
        this.id = id;
    }

    public java.lang.String getLogin() {
        return this.login;
    }

    public void setLogin(java.lang.String login) {
        this.login = login;
    }

    public java.lang.String getMdp() {
        return this.mdp;
    }

    public void setMdp(java.lang.String mdp) {
        this.mdp = mdp;
    }

    public String toString() {
        return new ToStringBuilder(this)
            .append("id", getId())
            .toString();
    }

    public boolean equals(Object other) {
        if ( !(other instanceof Utilisateur) ) return false;
        Utilisateur castOther = (Utilisateur) other;
        return new EqualsBuilder()
            .append(this.getId(), castOther.getId())
            .isEquals();
    }

    public int hashCode() {
        return new HashCodeBuilder()
            .append(getId())
            .toHashCode();
    }

}


And that includes the identifier....
What version are you using ?

/max

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 16, 2003 5:28 am 
Beginner
Beginner

Joined: Mon Sep 15, 2003 9:10 am
Posts: 43
your right again i was using an old hibernate.jar instear of hibernate2.jar

sorry for this error of a null beginner !


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.