-->
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: Help on DB2 needed
PostPosted: Fri May 21, 2004 5:31 am 
Beginner
Beginner

Joined: Fri May 21, 2004 5:22 am
Posts: 24
Hello there,

I am using Hibernate 2.1 rc1 (I think so), my mapping documents consists of a few files (reply me if need).

This is the DB DDL:

Code:
CREATE TABLE SEC.SEC_MENU (
   MENU_ID INTEGER NOT NULL,
   MODULE_URL VARCHAR ( 100 ),
   SEQ INTEGER,
   PARENT_MENU_ID INTEGER,
   MENU_DESC VARCHAR ( 50 ) NOT NULL,
   MENU_DESC_CODE VARCHAR ( 50 ),
   IMAGE_URL VARCHAR ( 20 ),
   HELP_URL SMALLINT,
   HIDDEN CHARACTER ( 1 ) DEFAULT 'N',
   STATUS CHARACTER ( 1 ) DEFAULT 'A',
   CONSTRAINT PK_MENU PRIMARY KEY (MENU_ID)
   );
CREATE TABLE SEC.SEC_USER_PREFERENCE (
   USER_ID INTEGER NOT NULL,
   LANG CHARACTER ( 2 ) DEFAULT 'en',
   XML_MENU VARCHAR(1000),
   CONSTRAINT PK_USER_PREFERENCE PRIMARY KEY (USER_ID)
   );
CREATE TABLE SEC.SEC_MENU_ACCESS (
   GRP_ID SMALLINT NOT NULL,
   MENU_ID INTEGER NOT NULL,
   ACTION VARCHAR ( 10 ) NOT NULL,
   CREATE_BY VARCHAR ( 20 ),
   CREATE_DT TIMESTAMP,
   CONSTRAINT PK_MENU_ACCESS PRIMARY KEY (GRP_ID, ACTION, MENU_ID)
   );
CREATE TABLE SEC.SEC_GRP_MEMBER (
   USER_ID INTEGER NOT NULL,
   GRP_ID SMALLINT NOT NULL,
   CREATE_BY VARCHAR ( 20 ),
   CREATE_DT TIMESTAMP,
   CONSTRAINT PK_USER_GRP PRIMARY KEY (USER_ID, GRP_ID)
   );
CREATE TABLE SEC.SEC_USER (
   USER_ID INTEGER NOT NULL,
   LOGIN_NAME VARCHAR ( 20 ) NOT NULL,
   FULL_NAME VARCHAR ( 30 ) NOT NULL,
   EMAIL VARCHAR ( 60 ) NOT NULL,
   PWD VARCHAR ( 32 ),
   FIRST_LOGIN_DT TIMESTAMP,
   EFFECTIVE_DT DATE,
   EXPIRY_DT DATE,
   FORCE_CHG_PWD CHARACTER ( 1 ) DEFAULT 'Y',
   STATUS CHARACTER ( 1 ) DEFAULT 'A',
   CREATE_BY VARCHAR ( 20 ),
   CREATE_DT TIMESTAMP,
   UPDATE_BY VARCHAR ( 20 ),
   UPDATE_DT TIMESTAMP,
   ROW_VERSION SMALLINT DEFAULT 1,
   CONSTRAINT PK_SEC_USER PRIMARY KEY (USER_ID)
   );
CREATE TABLE SEC.SEC_GRP (
   GRP_ID SMALLINT NOT NULL,
   GRP_CODE CHARACTER ( 10 ) NOT NULL,
   GRP_DESC VARCHAR ( 30 ) NOT NULL,
   GRP_DESC_CODE VARCHAR ( 50 ),
   STATUS CHARACTER ( 1 ) DEFAULT 'A' NOT NULL,
   CREATE_BY VARCHAR ( 20 ),
   CREATE_DT TIMESTAMP,
   UPDATE_BY VARCHAR ( 20 ) ,
   UPDATE_DT TIMESTAMP,
   ROW_VERSION SMALLINT DEFAULT 1,
   CONSTRAINT PK_SEC_GRP1 PRIMARY KEY (GRP_ID)
   );
CREATE INDEX IDX_LOGIN_NAME ON SEC.SEC_USER (LOGIN_NAME)PCTFREE 0;
ALTER TABLE SEC.SEC_USER_PREFERENCE ADD CONSTRAINT FK_USER_PREFERENCE FOREIGN KEY (USER_ID) REFERENCES SEC.SEC_USER (USER_ID)  ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE SEC.SEC_MENU_ACCESS ADD CONSTRAINT FK_MENU_ACCESS6 FOREIGN KEY (GRP_ID) REFERENCES SEC.SEC_GRP (GRP_ID)  ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE SEC.SEC_MENU_ACCESS ADD CONSTRAINT FK_MENU_ACCESS7 FOREIGN KEY (MENU_ID) REFERENCES SEC.SEC_MENU (MENU_ID)  ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE SEC.SEC_GRP_MEMBER ADD CONSTRAINT FK_USER_GRP1 FOREIGN KEY (USER_ID) REFERENCES SEC.SEC_USER (USER_ID)  ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE SEC.SEC_GRP_MEMBER ADD CONSTRAINT FK_USER_GRP0 FOREIGN KEY (GRP_ID) REFERENCES SEC.SEC_GRP (GRP_ID)  ON DELETE NO ACTION ON UPDATE NO ACTION;
COMMENT ON TABLE SEC.SEC_MENU IS 'Menu for the base. Typically link to strut action url';
COMMENT ON TABLE SEC.SEC_USER IS 'Store User or Principal Information.';
COMMENT ON TABLE SEC.SEC_GRP IS 'Group Name';
COMMENT ON COLUMN SEC.SEC_MENU.MODULE_URL IS 'Relative URL for the module.';
COMMENT ON COLUMN SEC.SEC_MENU.PARENT_MENU_ID IS 'When is null. Thats means this is the top menu';
COMMENT ON COLUMN SEC.SEC_MENU.MENU_DESC IS 'Descritpion based on language';
COMMENT ON COLUMN SEC.SEC_MENU.IMAGE_URL IS 'Used when the different menu is having different image and different page use a special image. ';
COMMENT ON COLUMN SEC.SEC_MENU.HELP_URL IS 'URL for the help file';
COMMENT ON COLUMN SEC.SEC_MENU.HIDDEN IS 'Determine whether this menu will be hidden
Y = Yes
N = No
';
COMMENT ON COLUMN SEC.SEC_MENU.STATUS IS 'A=Active
I=Disable (no security is given to any user and will not be shown)';
COMMENT ON COLUMN SEC.SEC_USER_PREFERENCE.USER_ID IS 'unique ID for the user.';
COMMENT ON COLUMN SEC.SEC_USER_PREFERENCE.XML_MENU IS 'XML menu generated based on user access from MENU';
COMMENT ON COLUMN SEC.SEC_MENU_ACCESS.GRP_ID IS 'Unique ID generated for the user Group';
COMMENT ON COLUMN SEC.SEC_MENU_ACCESS.ACTION IS 'Type of action that is allow for this particular module. Can be retrieved from Action Bean that implement SecAction.

Can be
1. CREATE
2. UPDATE
3. VIEW
4.  DELETE
5. and other
';
COMMENT ON COLUMN SEC.SEC_GRP_MEMBER.USER_ID IS 'unique ID for the user.';
COMMENT ON COLUMN SEC.SEC_GRP_MEMBER.GRP_ID IS 'Unique ID generated for the user Group';
COMMENT ON COLUMN SEC.SEC_GRP_MEMBER.CREATE_BY IS 'User for create this record';
COMMENT ON COLUMN SEC.SEC_GRP_MEMBER.CREATE_DT IS 'Date when this record is being created';
COMMENT ON COLUMN SEC.SEC_USER.USER_ID IS 'unique ID for the user.';
COMMENT ON COLUMN SEC.SEC_USER.LOGIN_NAME IS 'Login name for user to login to the system. User Name may not be unique if the application allwo recycle of name';
COMMENT ON COLUMN SEC.SEC_USER.FULL_NAME IS 'User''s Full Name';
COMMENT ON COLUMN SEC.SEC_USER.EMAIL IS 'Email Address. mandatory as password will be sent to this user using email';
COMMENT ON COLUMN SEC.SEC_USER.PWD IS 'Encoded password for user. This password will be hashed using MD5 Algorithm';
COMMENT ON COLUMN SEC.SEC_USER.EFFECTIVE_DT IS 'Date, including this date when the user are allow to login';
COMMENT ON COLUMN SEC.SEC_USER.EXPIRY_DT IS 'the last date for the user to use the system before  expiry';
COMMENT ON COLUMN SEC.SEC_USER.FORCE_CHG_PWD IS 'Force Change Password
Y= Yes
N = No
';
COMMENT ON COLUMN SEC.SEC_USER.STATUS IS 'A = Active
I=In-Active
D=Deleted (Can never change back to active)';
COMMENT ON COLUMN SEC.SEC_USER.CREATE_BY IS 'User for create this record';
COMMENT ON COLUMN SEC.SEC_USER.CREATE_DT IS 'Date when this record is being created';
COMMENT ON COLUMN SEC.SEC_USER.UPDATE_BY IS 'User for create /update this record';
COMMENT ON COLUMN SEC.SEC_USER.UPDATE_DT IS 'Date when this record is being created/updated';
COMMENT ON COLUMN SEC.SEC_GRP.GRP_ID IS 'Unique ID generated for the user Group';
COMMENT ON COLUMN SEC.SEC_GRP.GRP_CODE IS 'Unique Code for the user group';
COMMENT ON COLUMN SEC.SEC_GRP.GRP_DESC IS 'default description';
COMMENT ON COLUMN SEC.SEC_GRP.GRP_DESC_CODE IS 'system generated field. used in multi-lingua';
COMMENT ON COLUMN SEC.SEC_GRP.STATUS IS 'A= Active
D= Delete
I=Inactive';
COMMENT ON COLUMN SEC.SEC_GRP.CREATE_BY IS 'User for create this record';
COMMENT ON COLUMN SEC.SEC_GRP.UPDATE_BY IS 'User for create /update this record';
COMMENT ON COLUMN SEC.SEC_GRP.UPDATE_DT IS 'Date when this record is being created/updated';
COMMENT ON COLUMN SEC.SEC_GRP.ROW_VERSION IS 'col to to the version of the records';



The java code is integrated with spring framework:

Code:
public class SecUserDaoImpTest extends TestCase {
    private SecUserDao su;

    protected void setUp() throws Exception {
        ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(getContextLocation());
        su = (SecUserDao) ctx.getBean("secuser");
    }

    protected String getContextLocation() {
        return "hibernate.xml";
    }

    public void testFindUser() {
        SecUser secuser;
        secuser = su.findUser("David");
        assertEquals("David", secuser.getLoginName());
        secuser = su.findUser("Danny");
        assertEquals(null, secuser.getLoginName());
    }

    public static void main(String[] arg) {
        try {
            SecUserDaoImpTest test = new SecUserDaoImpTest();
            test.setUp();
            test.testFindUser();
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
}


Some log from log4j:

Code:
DEBUG - found http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd in classpath
INFO - Mapping class: com.thetasp.sec.data.SecMenu -> SEC_MENU
DEBUG - Mapped property: menuId -> MENU_ID, type: integer
DEBUG - Mapped property: moduleUrl -> MODULE_URL, type: string
DEBUG - Mapped property: seq -> SEQ, type: integer
DEBUG - Mapped property: parentMenuId -> PARENT_MENU_ID, type: integer
DEBUG - Mapped property: menuDesc -> MENU_DESC, type: string
DEBUG - Mapped property: menuDescCode -> MENU_DESC_CODE, type: string
DEBUG - Mapped property: imageUrl -> IMAGE_URL, type: string
DEBUG - Mapped property: helpUrl -> HELP_URL, type: short
DEBUG - Mapped property: hidden -> HIDDEN, type: string
DEBUG - Mapped property: status -> STATUS, type: string
DEBUG - Mapped property: secMenuAcces, type: java.util.Set
INFO - Building new Hibernate SessionFactory
INFO - processing one-to-many association mappings
DEBUG - Second pass for collection: com.thetasp.sec.data.SecMenu.secMenuAcces
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [hibernate.xml]: Initialization of bean failed; nested exception is net.sf.hibernate.MappingException: Association references unmapped class: com.thetasp.sec.data.SecMenuAcces
net.sf.hibernate.MappingException: Association references unmapped class: com.thetasp.sec.data.SecMenuAcces
   at net.sf.hibernate.cfg.Binder.bindCollectionSecondPass(Binder.java:1096)
   at net.sf.hibernate.cfg.Binder.bindSetSecondPass(Binder.java:1010)
   at net.sf.hibernate.cfg.Binder$SetSecondPass.secondPass(Binder.java:1332)
   at net.sf.hibernate.cfg.Binder$SecondPass.doSecondPass(Binder.java:1280)
   at net.sf.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:570)
   at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:713)
   at org.springframework.orm.hibernate.LocalSessionFactoryBean.newSessionFactory(LocalSessionFactoryBean.java:417)
   at org.springframework.orm.hibernate.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:355)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:718)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:213)
   at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:159)
   at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:172)
   at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:272)
   at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:58)
   at com.thetasp.sec.imp.dao.SecUserDaoImpTest.setUp(SecUserDaoImpTest.java:31)
   at com.thetasp.sec.imp.dao.SecUserDaoImpTest.main(SecUserDaoImpTest.java:50)


I am using IBM DB/2 8.1.2 Enterprise Edition.

Can someone tell me whats going wrong of this error?

Thanks

Neo


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 21, 2004 9:24 am 
Senior
Senior

Joined: Fri Nov 21, 2003 5:55 am
Posts: 155
It's seems one of your mapping files is not loaded.
I think you forget to map one class.
So show your mapping files and look your DB relationship maybe problem comes from one of them.


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 21, 2004 10:05 pm 
Beginner
Beginner

Joined: Fri May 21, 2004 5:22 am
Posts: 24
Hello,

Thanks for replying. The only mapping files that are not loaded are 2 hbm.xml with PK as suffix, does it sounds reasonable the problem from?

Thanks

Neo


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.