Tried it with the identity generator class and i got the subsection_id to be auto_incrementing.. when all I want to do is for the pageLinkId to be auto_incrementing..!
package com.sovision.cmsCore.persistence;
import org.appfuse.persistence.BaseObject;
/**
* This class represents the website pages.
*
* @hibernate.class table="SubSection_Page"
*
* @author julian
*
*/
public class PageLink extends BaseObject {
///////////////////////////////////////
// attributes
protected Long pageLinkId;
protected Page linkedPage;
protected SubSection subSection;
protected int order;
/**
* Returns the pageLinkId.
*
* @return Long
*
* @hibernate.id generator-class="identity"
*
*
*/
public Long getPageLinkId() {
return pageLinkId;
}
/**
* @hibernate.many-to-one column="Page_ID" class="com.sovision.cmsCore.persistence.Page"
*
* @return Page
*
*/
public Page getLinkedPage() {
return linkedPage;
}
/**
* @hibernate.many-to-one column="SubSection_ID" class="com.sovision.cmsCore.persistence.SubSection"
*
* @return SubSection
*
*/
public SubSection getSubSection() {
return subSection;
}
/**
* @hibernate.property column="Ind" not-null="true" insert="false" update="false"
*
* @return int
*/
public int getOrder() {
return order;
}
/**
* @param i
*/
public void setPageLinkId(Long i) {
pageLinkId = i;
}
/**
* @param linkedPage
*/
public void setLinkedPage(Page page) {
this.linkedPage = page;
}
/**
* @param section
*/
public void setSubSection(SubSection section) {
subSection = section;
}
/**
* @param i
*/
public void setOrder(int i) {
order = i;
}
}
Schema Tables:
[schemaexport] create table SubSection (
[schemaexport] subSectionId BIGINT NOT NULL AUTO_INCREMENT,
[schemaexport] live BIT not null,
[schemaexport] section BIGINT not null,
[schemaexport] title VARCHAR(255) not null,
[schemaexport] url VARCHAR(255),
[schemaexport] ord INTEGER not null,
[schemaexport] list BIT not null,
[schemaexport] restricted BIT not null,
[schemaexport] primary key (subSectionId)
[schemaexport] )
[schemaexport] create table Section (
[schemaexport] sectionId BIGINT NOT NULL AUTO_INCREMENT,
[schemaexport] title VARCHAR(60) not null,
[schemaexport] ord INTEGER,
[schemaexport] live BIT not null,
[schemaexport] primary key (sectionId)
[schemaexport] )
[schemaexport] create table user_role (
[schemaexport] id BIGINT NOT NULL AUTO_INCREMENT,
[schemaexport] user_id BIGINT not null,
[schemaexport] username VARCHAR(255) not null,
[schemaexport] role_name VARCHAR(255) not null,
[schemaexport] primary key (id)
[schemaexport] )
[schemaexport] create table app_user (
[schemaexport] id BIGINT NOT NULL AUTO_INCREMENT,
[schemaexport] username VARCHAR(255) not null unique,
[schemaexport] password VARCHAR(255) not null,
[schemaexport] firstName VARCHAR(255) not null,
[schemaexport] lastName VARCHAR(255) not null,
[schemaexport] address VARCHAR(255),
[schemaexport] city VARCHAR(255) not null,
[schemaexport] country VARCHAR(100),
[schemaexport] email VARCHAR(255) unique,
[schemaexport] phoneNumber VARCHAR(255),
[schemaexport] postalCode VARCHAR(255) not null,
[schemaexport] province VARCHAR(100),
[schemaexport] website VARCHAR(255),
[schemaexport] passwordHint VARCHAR(255),
[schemaexport] primary key (id)
[schemaexport] )
[schemaexport] create table role (
[schemaexport] name VARCHAR(255) not null,
[schemaexport] description VARCHAR(255),
[schemaexport] primary key (name)
[schemaexport] )
[schemaexport] create table SubSection_Page (
[schemaexport] pageLinkId BIGINT not null,
[schemaexport] Page_ID BIGINT,
[schemaexport] SubSection_ID BIGINT NOT NULL AUTO_INCREMENT,
[schemaexport] Ind INTEGER not null,
[schemaexport] primary key (SubSection_ID, Ind)
[schemaexport] )
[schemaexport] create table Page (
[schemaexport] pageId BIGINT NOT NULL AUTO_INCREMENT,
[schemaexport] modified DATETIME not null,
[schemaexport] User_ID BIGINT,
[schemaexport] content TEXT,
[schemaexport] live BIT not null,
[schemaexport] title VARCHAR(255) not null,
[schemaexport] primary key (pageId)
[schemaexport] )
[schemaexport] alter table SubSection add index (section), add constraint FK93F1ACA5756F7EE5 foreign key (section) references Section (sectionId)
[schemaexport] alter table SubSection_Page add index (SubSection_ID), add constraint FKDB2A020968EB42F5 foreign key (SubSection_ID) references SubSection (subSectionId)
[schemaexport] alter table SubSection_Page add index (Page_ID), add constraint FKDB2A0209335364AB foreign key (Page_ID) references Page (pageId)
[schemaexport] alter table Page add index (User_ID), add constraint FK25D6AF5A7381EF foreign key (User_ID) references app_user (id)
[schemaexport] (hbm2ddl.SchemaExport 160 ) schema export complete
[schemaexport] (connection.DriverManagerConnectionProvider 137 ) cleaning up connection pool: jdbc:mysql://localhost:3306/socms?autoReconnect=true
BUILD SUCCESSFUL
Total time: 31 seconds
Julian
|