facebook

[Closed] Confusion on how Myeclipse generates ID classes

  1. MyEclipse Archived
  2.  > 
  3. Database Tools (DB Explorer, Hibernate, etc.)
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #270183 Reply

    fullerj
    Member

    I am generating classes for two MySQL tables. The relevant DDL is:

    CREATE TABLE RLCMConfig (
    ManagedElementId VARCHAR(36) NOT NULL,
    PRIMARY KEY (ManagedElementId)
    );

    CREATE TABLE Service (
    ManagedElementId VARCHAR(36) NOT NULL,
    ServiceName VARCHAR(64) NOT NULL,
    PRIMARY KEY (ManagedElementId, ServiceName),
    FOREIGN KEY (ManagedElementId)
    REFERENCES RLCMConfiguration(ManagedElementId)
    );

    A ServiceId class is automatically generated as shown below:

    public class ServiceId implements java.io.Serializable {
    // Fields
    private Rlcmconfig rlcmconfig;
    private String serviceName;

    // Constructors

    }

    My question is why is the foreign key an instance of the class Rlcmconfig, when I generated comparable classes from the following DDL:

    CREATE TABLE Attributes (
    AttributeId VARCHAR(64) NOT NULL,
    PRIMARY KEY (AttributeId)
    );

    CREATE TABLE ReportCriteriaRollup (
    AttributeId VARCHAR(64) NOT NULL,
    TrendNumber INTEGER NOT NULL,
    PRIMARY KEY (AttributeId, TrendNumber),
    FOREIGN KEY (AttributeId)
    REFERENCES Attribute(AttributeId)
    );

    and I get this class for ReportCriteriaRollupId:

    public class ReportcriteriarollupId implements java.io.Serializable {
    // Fields
    private String attributeId;
    private Integer trendNumber;

    // Constructors

    }

    These two situations seem to be exactly the same as far as the DDL goes, yet I get very different IDs, the latter being the one I would expect. Does anyone know where the difference comes from – is there some setting that can affect the way these are generated. BTW, I am not using any custom templates in either case.

    Thanks.

    #270312 Reply

    fullerj
    Member

    I figured out the difference – on the second display in the wizard’s sequence there is a check box under “ID Generator” labeled “Generate basic typed composite IDs” that when checked generates the second style ID listed in my original post (i.e., ReportcriteriarollupId) rather than the default that was generated for ServiceId.

    So, the problem all along was me being a little dim – the norm for me.

    Since I am fairly new to Hibernate, I would appreciate any comments on the advantages to one over the other or any other info that would help me understand when each should be used.

    Thanks and sorry if I wasted anyone’s time.

    #270332 Reply

    Riyad Kalla
    Member

    fullerj,
    I’m very sorry for the delay in responding. I was in the midst of getting an answer for you when you replied. We really appreciate you following up for others.

Viewing 3 posts - 1 through 3 (of 3 total)
Reply To: [Closed] Confusion on how Myeclipse generates ID classes

You must be logged in to post in the forum log in