Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Author Message
thurisaz
Post subject: Problems with "references" and Hibernate-Mappings  PostPosted: Feb 05, 2006 - 11:02 PM
Registered Member
Registered Member


Joined: Dec 12, 2004
Posts: 23

Hi everybody,

a few months ago I created a lot of SQL-Tables in Postgresql and when I used MyEclipse to create JavaBeans and Mapping files from these tables with "referenced"-table-attributes like

Code:
CREATE TABLE Category
(

[...]   father REFERENCES Category  ON UPDATE CASCADE ON DELETE CASCADE, [...]



MyEclipse created JavaBeans with an attribute named "father" which references another Java-Class from type "Category".
Code:

private Category father;

Today, using MyEclipse 4.1 I tried something simmilar using MySQL. When I create a table with

Code:
CREATE TABLE `Repository`
(
[...]
`owner` INTEGER NOT NULL,
FOREIGN KEY (owner) REFERENCES user(userid) ON DELETE CASCADE ON UPDATE CASCADE
) TYPE = innodb;


and then try to create Java-Classes from this Table using the MyEclipse "Create Hibernate Mapping"-functionality, I get the following:

Code:
public class Cssrepository extends User implements java.io.Serializable {


    // Fields   
[...]
     private Integer owner;
[...]



Why does this Class extends from User??? And why is my attribute "owner" a normal "Integer" instead of a reference to an Java-Object from type "User"

Is this a bug? I have this problems since 4.1pre and I hoped that this was solved with the final version - but the problems are still the same. Am I doing something wrong?
 
 View user's profile Send private message  
Reply with quote Back to top
support-snpe
Post subject:   PostPosted: Feb 06, 2006 - 02:05 AM
Moderator
Moderator


Joined: Feb 03, 2006
Posts: 1117

it is bug for any databases (probably).Can you send schema that i check ?
 
 View user's profile Send private message  
Reply with quote Back to top
thurisaz
Post subject:   PostPosted: Feb 06, 2006 - 08:34 AM
Registered Member
Registered Member


Joined: Dec 12, 2004
Posts: 23

I'm quite sure that the "Create Hibernate Mapping"-Feature is currently totally unusable but I just tried it with MySQL.

If you take these SQL-Schemas

Code:
CREATE TABLE user
(
   userid INTEGER PRIMARY KEY,
   username CHAR(30),
   password CHAR(100)
)


Code:
CREATE TABLE `CssRepository`
(
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`name` VARCHAR( 255 ) NOT NULL ,
`description` VARCHAR( 255 ) NOT NULL ,
`dateofcreation` DATETIME NOT NULL ,
`lastmodified` DATETIME NOT NULL ,
`owner` INTEGER REFERENCES User ON UPDATE CASCADE ON DELETE CASCADE
) TYPE = innodb;


MySQL successfully creates a reference from Cssrepository to User, but MyEclipse doesn't care about it

Also MyEclipse generates senseless "extends xyz"-strings (independent from any "reference"-string, I already had things like "MyClass extends MyClass")

Code:
public class Cssrepository extends User implements java.io.Serializable {


    // Fields   

     private Integer id;
     private String name;
     private String description;
     private Date dateofcreation;
     private Date lastmodified;
     private Integer owner;


    // Constructors

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

   
    /** full constructor */
    public Cssrepository(String name, String description, Date dateofcreation, Date lastmodified, Integer owner) {
        this.name = name;
        this.description = description;
        this.dateofcreation = dateofcreation;
        this.lastmodified = lastmodified;
        this.owner = owner;
    }
   

   
    // Property accessors

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

    public String getName() {
        return this.name;
    }
   
    public void setName(String name) {
        this.name = name;
    }

    public String getDescription() {
        return this.description;
    }
   
    public void setDescription(String description) {
        this.description = description;
    }

    public Date getDateofcreation() {
        return this.dateofcreation;
    }
   
    public void setDateofcreation(Date dateofcreation) {
        this.dateofcreation = dateofcreation;
    }

    public Date getLastmodified() {
        return this.lastmodified;
    }
   
    public void setLastmodified(Date lastmodified) {
        this.lastmodified = lastmodified;
    }

    public Integer getOwner() {
        return this.owner;
    }
   
    public void setOwner(Integer owner) {
        this.owner = owner;
    }


Code:
<hibernate-mapping>
    <class name="xyz.Cssrepository" table="cssrepository" catalog="csseditor">
        <id name="id" type="java.lang.Integer">
            <column name="id" />
            <generator class="increment" />
        </id>
        <property name="name" type="java.lang.String">
            <column name="name" not-null="true" />
        </property>
        <property name="description" type="java.lang.String">
            <column name="description" not-null="true" />
        </property>
        <property name="dateofcreation" type="java.util.Date">
            <column name="dateofcreation" length="19" not-null="true" />
        </property>
        <property name="lastmodified" type="java.util.Date">
            <column name="lastmodified" length="19" not-null="true" />
        </property>
        <property name="owner" type="java.lang.Integer">
            <column name="owner" not-null="true" />
        </property>
    </class>
</hibernate-mapping>


So I think there are two Bugs: first: senseless extends-expressions and second MyEclipse doesn't take care about references... but maybe this is just a MyEclipse - MySQL- Bug?
 
 View user's profile Send private message  
Reply with quote Back to top
thurisaz
Post subject:   PostPosted: Feb 07, 2006 - 09:58 AM
Registered Member
Registered Member


Joined: Dec 12, 2004
Posts: 23

are there any news yet? is it a bug or am I doing something wrong (wrong DB-drivers or anything else)?
 
 View user's profile Send private message  
Reply with quote Back to top
Support-Brian
Post subject:   PostPosted: Feb 07, 2006 - 10:50 AM
Moderator
Moderator


Joined: Aug 21, 2004
Posts: 2339

Thurisaz,

I apologize for the delayed response. No, you aren't doing anything wrong, the reference issue a bug and it will be addressed in 4.1.1.

Having said that, I'm afraid I could not understand what you meant by "senseless extends-expressions". Are you talking about
Code:

public class Cssrepository extends User

or did you mean something else?

Sorry for the inconvenience and thank you for reporting the issue.

Best,
Brian.

_________________
Brian
MyEclipse Support
 
 View user's profile Send private message Visit poster's website  
Reply with quote Back to top
thurisaz
Post subject:   PostPosted: Feb 07, 2006 - 11:35 AM
Registered Member
Registered Member


Joined: Dec 12, 2004
Posts: 23

Thank you for your answer Brian! Well, if I create a hibernate mapping from my "User"-Table [CREATE TABLE user ( userid INTEGER PRIMARY KEY, username CHAR(30), password CHAR(100) ) ] the created class ALWAYS extends from the same class:

public class User extends User implements java.io.Serializable {

[...]
}

This is just a simple example - I have this "extends"-problems with a lot of other classes too!

When will 4.1.1 be released? 'Cause this bug creates some troubles in our roadmap.
 
 View user's profile Send private message  
Reply with quote Back to top
thurisaz
Post subject:   PostPosted: Feb 07, 2006 - 11:43 AM
Registered Member
Registered Member


Joined: Dec 12, 2004
Posts: 23

Can you reproduce this bug?
 
 View user's profile Send private message  
Reply with quote Back to top
Support-Brian
Post subject:   PostPosted: Feb 07, 2006 - 11:47 AM
Moderator
Moderator


Joined: Aug 21, 2004
Posts: 2339

Thurisaz,

About the extends issue, on the first page of the RE wizard, there is a text box for "Base persistence class". You probably have "User" in there, if you remove it, the generated classes won't extend anytying (except if you chose to generate abstract classes).
I hope I'm talking about the same issue you're facing here, let me know if it isn't.

4.1.1 is due late February, it is, for most part a maintanence and bug fix only release; and we're trying to get it out asap.

We were able to reproduce the reference issue.

Best,
Brian.

_________________
Brian
MyEclipse Support
 
 View user's profile Send private message Visit poster's website  
Reply with quote Back to top
thurisaz
Post subject:   PostPosted: Feb 07, 2006 - 12:04 PM
Registered Member
Registered Member


Joined: Dec 12, 2004
Posts: 23

Support-Brian wrote:
About the extends issue, on the first page of the RE wizard, there is a text box for "Base persistence class". You probably have "User" in there, if you remove it, the generated classes won't extend anytying (except if you chose to generate abstract classes).
I hope I'm talking about the same issue you're facing here, let me know if it isn't.


You're right I thought that "Base persistent class" belongs to "Create abstract class" and I thought that the entry is ignored if I don't want abstract classes.

Thanks this extends-problem is solved - your support in this forum is really excellent!
 
 View user's profile Send private message  
Reply with quote Back to top
Support-Brian
Post subject:   PostPosted: Feb 07, 2006 - 12:11 PM
Moderator
Moderator


Joined: Aug 21, 2004
Posts: 2339

Thurisaz,

Thank you for the compliment :). We will take another look at the UI of that page as it conveyed the wrong message to you.

Best regards,
Brian.

_________________
Brian
MyEclipse Support
 
 View user's profile Send private message Visit poster's website  
Reply with quote Back to top
Display posts from previous:     
Jump to:  
All times are GMT - 6 Hours
Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Powered by PNphpBB2 © 2003-2004 The PNphpBB Group
Credits