facebook

Hibernate file generation problem in Myeclipse 5.0

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

    nisingh
    Member

    I am using myeclipse 5.0. I am unable to generate the mapping as well as the java class properly. I am using Hibernate with MS SQL server 2005.

    My table script is :

    IF EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_cps_nongsb_course_request_l_source]’) AND parent_object_id = OBJECT_ID(N'[dbo].[cps_nongsb_course_request]’))
    ALTER TABLE [dbo].[cps_nongsb_course_request] DROP CONSTRAINT [FK_cps_nongsb_course_request_l_source]
    GO
    IF EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_cps_nongsb_course_request_nongsb_course_offer]’) AND parent_object_id = OBJECT_ID(N'[dbo].[cps_nongsb_course_request]’))
    ALTER TABLE [dbo].[cps_nongsb_course_request] DROP CONSTRAINT [FK_cps_nongsb_course_request_nongsb_course_offer]
    GO
    IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[cps_nongsb_course_request]’) AND type in (N’U’))
    DROP TABLE [dbo].[cps_nongsb_course_request]

    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    SET ANSI_PADDING ON
    GO
    IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[cps_nongsb_course_request]’) AND type in (N’U’))
    BEGIN
    CREATE TABLE [dbo].[cps_nongsb_course_request](
    [nongsb_course_request_id] [int] IDENTITY(1,1) NOT NULL,
    [nongsb_course_offer_id] [int] NULL,
    [nongsb_dept_code] [varchar](16) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
    [nongsb_subject_code] [varchar](16) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
    [nongsb_catalog_number] [varchar](16) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
    [created_by] [varchar](32) NOT NULL CONSTRAINT [DF_cps_nongsb_course_request_created_by] DEFAULT (suser_sname()),
    [modified_by] [varchar](32) NULL,
    [source] [varchar](32) NOT NULL CONSTRAINT [DF_cps_nongsb_course_request_source] DEFAULT (‘.’),
    [date_created] [datetime] NOT NULL CONSTRAINT [DF_cps_nongsb_course_request_date_created] DEFAULT (getdate()),
    [date_modified] [datetime] NULL,
    [date_modified_source] [datetime] NULL,
    CONSTRAINT [PK_nongsb_course_request] PRIMARY KEY CLUSTERED
    (
    [nongsb_course_request_id] ASC
    )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
    ) ON [PRIMARY]
    END
    GO
    SET ANSI_PADDING OFF

    IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_cps_nongsb_course_request_l_source]’) AND parent_object_id = OBJECT_ID(N'[dbo].[cps_nongsb_course_request]’))
    ALTER TABLE [dbo].[cps_nongsb_course_request] WITH CHECK ADD CONSTRAINT [FK_cps_nongsb_course_request_l_source] FOREIGN KEY([source])
    REFERENCES [dbo].[l_source] ([source])
    GO
    ALTER TABLE [dbo].[cps_nongsb_course_request] CHECK CONSTRAINT [FK_cps_nongsb_course_request_l_source]
    GO
    IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_cps_nongsb_course_request_nongsb_course_offer]’) AND parent_object_id = OBJECT_ID(N'[dbo].[cps_nongsb_course_request]’))
    ALTER TABLE [dbo].[cps_nongsb_course_request] WITH CHECK ADD CONSTRAINT [FK_cps_nongsb_course_request_nongsb_course_offer] FOREIGN KEY([nongsb_course_offer_id])
    REFERENCES [dbo].[nongsb_course_offer] ([nongsb_course_offer_id])
    GO
    ALTER TABLE [dbo].[cps_nongsb_course_request] CHECK CONSTRAINT [FK_cps_nongsb_course_request_nongsb_course_offer]
    GO

    /* Creating table nongsb_course_request’ End*/

    The columns nongsb_course_offer_id has a refernece to a table nongsb_course_offer and the source has a reference to a table l_source.

    when I generate the hibernate related files , I got the following files which doesn’t contain any relationships. The files are as follows :

    <?xml version=”1.0″?>
    <!DOCTYPE hibernate-mapping PUBLIC “-//Hibernate/Hibernate Mapping DTD 3.0//EN”
    http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd”&gt;
    <!–
    Mapping file autogenerated by MyEclipse – Hibernate Tools
    –>
    <hibernate-mapping>
    <class name=”stanford.gsb.core.domain_new.CpsNongsbCourseRequest” table=”cps_nongsb_course_request” >
    <id name=”nongsbCourseRequestId” type=”java.lang.Integer”>
    <column name=”nongsb_course_request_id” />
    <generator class=”identity” />
    </id>
    <property name=”nongsbCourseOfferId” type=”java.lang.Integer”>
    <column name=”nongsb_course_offer_id” />
    </property>
    <property name=”nongsbDeptCode” type=”java.lang.String”>
    <column name=”nongsb_dept_code” length=”16″ />
    </property>
    <property name=”nongsbSubjectCode” type=”java.lang.String”>
    <column name=”nongsb_subject_code” length=”16″ />
    </property>
    <property name=”nongsbCatalogNumber” type=”java.lang.String”>
    <column name=”nongsb_catalog_number” length=”16″ />
    </property>
    <property name=”createdBy” type=”java.lang.String”>
    <column name=”created_by” length=”32″ not-null=”true” />
    </property>
    <property name=”modifiedBy” type=”java.lang.String”>
    <column name=”modified_by” length=”32″ />
    </property>
    <property name=”source” type=”java.lang.String”>
    <column name=”source” length=”32″ not-null=”true” />
    </property>
    <property name=”dateCreated” type=”java.util.Date”>
    <column name=”date_created” length=”23″ not-null=”true” />
    </property>
    <property name=”dateModified” type=”java.util.Date”>
    <column name=”date_modified” length=”23″ />
    </property>
    <property name=”dateModifiedSource” type=”java.util.Date”>
    <column name=”date_modified_source” length=”23″ />
    </property>
    </class>
    </hibernate-mapping>

    package stanford.gsb.core.domain_new;

    import java.util.Date;

    /**
    * AbstractCpsNongsbCourseRequest generated by MyEclipse – Hibernate Tools
    */

    public abstract class AbstractCpsNongsbCourseRequest implements java.io.Serializable {

    // Fields

    private Integer nongsbCourseRequestId;
    private Integer nongsbCourseOfferId;
    private String nongsbDeptCode;
    private String nongsbSubjectCode;
    private String nongsbCatalogNumber;
    private String createdBy;
    private String modifiedBy;
    private String source;
    private Date dateCreated;
    private Date dateModified;
    private Date dateModifiedSource;

    // Constructors

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

    /** minimal constructor */
    public AbstractCpsNongsbCourseRequest(String createdBy, String source, Date dateCreated) {
    this.createdBy = createdBy;
    this.source = source;
    this.dateCreated = dateCreated;
    }

    /** full constructor */
    public AbstractCpsNongsbCourseRequest(Integer nongsbCourseOfferId, String nongsbDeptCode, String nongsbSubjectCode, String nongsbCatalogNumber, String createdBy, String modifiedBy, String source, Date dateCreated, Date dateModified, Date dateModifiedSource) {
    this.nongsbCourseOfferId = nongsbCourseOfferId;
    this.nongsbDeptCode = nongsbDeptCode;
    this.nongsbSubjectCode = nongsbSubjectCode;
    this.nongsbCatalogNumber = nongsbCatalogNumber;
    this.createdBy = createdBy;
    this.modifiedBy = modifiedBy;
    this.source = source;
    this.dateCreated = dateCreated;
    this.dateModified = dateModified;
    this.dateModifiedSource = dateModifiedSource;
    }

    // Property accessors

    public Integer getNongsbCourseRequestId() {
    return this.nongsbCourseRequestId;
    }

    public void setNongsbCourseRequestId(Integer nongsbCourseRequestId) {
    this.nongsbCourseRequestId = nongsbCourseRequestId;
    }

    public Integer getNongsbCourseOfferId() {
    return this.nongsbCourseOfferId;
    }

    public void setNongsbCourseOfferId(Integer nongsbCourseOfferId) {
    this.nongsbCourseOfferId = nongsbCourseOfferId;
    }

    public String getNongsbDeptCode() {
    return this.nongsbDeptCode;
    }

    public void setNongsbDeptCode(String nongsbDeptCode) {
    this.nongsbDeptCode = nongsbDeptCode;
    }

    public String getNongsbSubjectCode() {
    return this.nongsbSubjectCode;
    }

    public void setNongsbSubjectCode(String nongsbSubjectCode) {
    this.nongsbSubjectCode = nongsbSubjectCode;
    }

    public String getNongsbCatalogNumber() {
    return this.nongsbCatalogNumber;
    }

    public void setNongsbCatalogNumber(String nongsbCatalogNumber) {
    this.nongsbCatalogNumber = nongsbCatalogNumber;
    }

    public String getCreatedBy() {
    return this.createdBy;
    }

    public void setCreatedBy(String createdBy) {
    this.createdBy = createdBy;
    }

    public String getModifiedBy() {
    return this.modifiedBy;
    }

    public void setModifiedBy(String modifiedBy) {
    this.modifiedBy = modifiedBy;
    }

    public String getSource() {
    return this.source;
    }

    public void setSource(String source) {
    this.source = source;
    }

    public Date getDateCreated() {
    return this.dateCreated;
    }

    public void setDateCreated(Date dateCreated) {
    this.dateCreated = dateCreated;
    }

    public Date getDateModified() {
    return this.dateModified;
    }

    public void setDateModified(Date dateModified) {
    this.dateModified = dateModified;
    }

    public Date getDateModifiedSource() {
    return this.dateModifiedSource;
    }

    public void setDateModifiedSource(Date dateModifiedSource) {
    this.dateModifiedSource = dateModifiedSource;
    }

    }

    package stanford.gsb.core.domain_new;
    // Generated by MyEclipse – Hibernate Tools

    import java.util.Date;

    /**
    * CpsNongsbCourseRequest generated by MyEclipse – Hibernate Tools
    */
    public class CpsNongsbCourseRequest extends AbstractCpsNongsbCourseRequest implements java.io.Serializable {

    // Constructors

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

    /** minimal constructor */
    public CpsNongsbCourseRequest(String createdBy, String source, Date dateCreated) {
    super(createdBy, source, dateCreated);
    }

    /** full constructor */
    public CpsNongsbCourseRequest(Integer nongsbCourseOfferId, String nongsbDeptCode, String nongsbSubjectCode, String nongsbCatalogNumber, String createdBy, String modifiedBy, String source, Date dateCreated, Date dateModified, Date dateModifiedSource) {
    super(nongsbCourseOfferId, nongsbDeptCode, nongsbSubjectCode, nongsbCatalogNumber, createdBy, modifiedBy, source, dateCreated, dateModified, dateModifiedSource);
    }

    }

    package stanford.gsb.core.domain_new;

    import java.util.Date;
    import java.util.List;
    import org.apache.commons.logging.Log;
    import org.apache.commons.logging.LogFactory;
    import org.hibernate.LockMode;
    import org.springframework.context.ApplicationContext;
    import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

    /**
    * Data access object (DAO) for domain model class CpsNongsbCourseRequest.
    * @see stanford.gsb.core.domain_new.CpsNongsbCourseRequest
    * @author MyEclipse – Hibernate Tools
    */
    public class CpsNongsbCourseRequestDAO extends HibernateDaoSupport {

    private static final Log log = LogFactory.getLog(CpsNongsbCourseRequestDAO.class);

    //property constants
    public static final String NONGSB_COURSE_OFFER_ID = “nongsbCourseOfferId”;
    public static final String NONGSB_DEPT_CODE = “nongsbDeptCode”;
    public static final String NONGSB_SUBJECT_CODE = “nongsbSubjectCode”;
    public static final String NONGSB_CATALOG_NUMBER = “nongsbCatalogNumber”;
    public static final String CREATED_BY = “createdBy”;
    public static final String MODIFIED_BY = “modifiedBy”;
    public static final String SOURCE = “source”;

    protected void initDao() {
    //do nothing
    }

    public void save(CpsNongsbCourseRequest transientInstance) {
    log.debug(“saving CpsNongsbCourseRequest instance”);
    try {
    getHibernateTemplate().save(transientInstance);
    log.debug(“save successful”);
    } catch (RuntimeException re) {
    log.error(“save failed”, re);
    throw re;
    }
    }

    public void delete(CpsNongsbCourseRequest persistentInstance) {
    log.debug(“deleting CpsNongsbCourseRequest instance”);
    try {
    getHibernateTemplate().delete(persistentInstance);
    log.debug(“delete successful”);
    } catch (RuntimeException re) {
    log.error(“delete failed”, re);
    throw re;
    }
    }

    public CpsNongsbCourseRequest findById( java.lang.Integer id) {
    log.debug(“getting CpsNongsbCourseRequest instance with id: ” + id);
    try {
    CpsNongsbCourseRequest instance = (CpsNongsbCourseRequest) getHibernateTemplate()
    .get(“stanford.gsb.core.domain_new.CpsNongsbCourseRequest”, id);
    return instance;
    } catch (RuntimeException re) {
    log.error(“get failed”, re);
    throw re;
    }
    }

    public List findByExample(CpsNongsbCourseRequest instance) {
    log.debug(“finding CpsNongsbCourseRequest instance by example”);
    try {
    List results = getHibernateTemplate().findByExample(instance);
    log.debug(“find by example successful, result size: ” + results.size());
    return results;
    } catch (RuntimeException re) {
    log.error(“find by example failed”, re);
    throw re;
    }
    }

    public List findByProperty(String propertyName, Object value) {
    log.debug(“finding CpsNongsbCourseRequest instance with property: ” + propertyName
    + “, value: ” + value);
    try {
    String queryString = “from CpsNongsbCourseRequest as model where model.”
    + propertyName + “= ?”;
    return getHibernateTemplate().find(queryString, value);
    } catch (RuntimeException re) {
    log.error(“find by property name failed”, re);
    throw re;
    }
    }

    public List findByNongsbCourseOfferId(Object nongsbCourseOfferId) {
    return findByProperty(NONGSB_COURSE_OFFER_ID, nongsbCourseOfferId);
    }

    public List findByNongsbDeptCode(Object nongsbDeptCode) {
    return findByProperty(NONGSB_DEPT_CODE, nongsbDeptCode);
    }

    public List findByNongsbSubjectCode(Object nongsbSubjectCode) {
    return findByProperty(NONGSB_SUBJECT_CODE, nongsbSubjectCode);
    }

    public List findByNongsbCatalogNumber(Object nongsbCatalogNumber) {
    return findByProperty(NONGSB_CATALOG_NUMBER, nongsbCatalogNumber);
    }

    public List findByCreatedBy(Object createdBy) {
    return findByProperty(CREATED_BY, createdBy);
    }

    public List findByModifiedBy(Object modifiedBy) {
    return findByProperty(MODIFIED_BY, modifiedBy);
    }

    public List findBySource(Object source) {
    return findByProperty(SOURCE, source);
    }

    public CpsNongsbCourseRequest merge(CpsNongsbCourseRequest detachedInstance) {
    log.debug(“merging CpsNongsbCourseRequest instance”);
    try {
    CpsNongsbCourseRequest result = (CpsNongsbCourseRequest) getHibernateTemplate()
    .merge(detachedInstance);
    log.debug(“merge successful”);
    return result;
    } catch (RuntimeException re) {
    log.error(“merge failed”, re);
    throw re;
    }
    }

    public void attachDirty(CpsNongsbCourseRequest instance) {
    log.debug(“attaching dirty CpsNongsbCourseRequest instance”);
    try {
    getHibernateTemplate().saveOrUpdate(instance);
    log.debug(“attach successful”);
    } catch (RuntimeException re) {
    log.error(“attach failed”, re);
    throw re;
    }
    }

    public void attachClean(CpsNongsbCourseRequest instance) {
    log.debug(“attaching clean CpsNongsbCourseRequest instance”);
    try {
    getHibernateTemplate().lock(instance, LockMode.NONE);
    log.debug(“attach successful”);
    } catch (RuntimeException re) {
    log.error(“attach failed”, re);
    throw re;
    }
    }

    public static CpsNongsbCourseRequestDAO getFromApplicationContext(ApplicationContext ctx) {
    return (CpsNongsbCourseRequestDAO) ctx.getBean(“CpsNongsbCourseRequestDAO”);
    }
    }

    The problem is the Foreign key fields are generated as simple fields. Please help me its urgent.

    #277514 Reply

    Loyal Water
    Member

    Whats the error that you are receiving ? Can you go to <workspace>/.metadata/.log file and check for errors.

    #277536 Reply

    nisingh
    Member

    I didn’t get any error.

    #277686 Reply

    Riyad Kalla
    Member

    This message has not been recovered.

Viewing 4 posts - 1 through 4 (of 4 total)
Reply To: Hibernate file generation problem in Myeclipse 5.0

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