PDA

View Full Version : contacts example mysql version



wangl@cmbchina
Sep 26th, 2008, 09:03 PM
hi
all,I want to replace hsqldb with mysql in contacts example.so I first created a
database named springacls,then I got a sql script from spring-security-acl-2.0.3.jar and modified it to mysql version ddl like this:
drop table if exists ACL_SID;

/*================================================= =============*/
/* Table: ACL_SID */
/*================================================= =============*/
create table ACL_SID
(
ID bigint auto_increment not null,
PRINCIPAL bool not null,
SID varchar(100) not null,
primary key (ID),
unique key ukey_1 (PRINCIPAL,SID)
)
auto_increment = 100;

DROP TABLE IF EXISTS ACL_CLASS;
CREATE TABLE ACL_CLASS(
ID BIGINT AUTO_INCREMENT NOT NULL PRIMARY KEY,
CLASS VARCHAR(100) NOT NULL,
UNIQUE KEY UNIQUE_UK_2 (CLASS))
auto_increment = 100;

INSERT INTO ACL_CLASS VALUES (1, 'sample.contact.Contact');


DROP TABLE IF EXISTS ACL_OBJECT_IDENTITY;
CREATE TABLE ACL_OBJECT_IDENTITY(
ID BIGINT AUTO_INCREMENT NOT NULL PRIMARY KEY,
OBJECT_ID_CLASS BIGINT NOT NULL,
OBJECT_ID_IDENTITY BIGINT NOT NULL,
PARENT_OBJECT BIGINT,
OWNER_SID BIGINT,
ENTRIES_INHERITING BOOLEAN NOT NULL,
UNIQUE KEY UNIQUE_UK_3 (OBJECT_ID_CLASS,OBJECT_ID_IDENTITY),
CONSTRAINT FOREIGN_FK_1 FOREIGN KEY(PARENT_OBJECT)REFERENCES ACL_OBJECT_IDENTITY(ID),
CONSTRAINT FOREIGN_FK_2 FOREIGN KEY(OBJECT_ID_CLASS)REFERENCES ACL_CLASS(ID),
CONSTRAINT FOREIGN_FK_3 FOREIGN KEY(OWNER_SID)REFERENCES ACL_SID(ID));


DROP TABLE IF EXISTS ACL_ENTRY;
CREATE TABLE ACL_ENTRY(
ID BIGINT AUTO_INCREMENT NOT NULL PRIMARY KEY,
ACL_OBJECT_IDENTITY BIGINT NOT NULL,
ACE_ORDER INT NOT NULL,
SID BIGINT NOT NULL,
MASK INTEGER NOT NULL,
GRANTING BOOLEAN NOT NULL,
AUDIT_SUCCESS BOOLEAN NOT NULL,
AUDIT_FAILURE BOOLEAN NOT NULL,
UNIQUE KEY UNIQUE_UK_4 (ACL_OBJECT_IDENTITY,ACE_ORDER),
CONSTRAINT FOREIGN_FK_4 FOREIGN KEY(ACL_OBJECT_IDENTITY) REFERENCES ACL_OBJECT_IDENTITY(ID),
CONSTRAINT FOREIGN_FK_5 FOREIGN KEY(SID) REFERENCES ACL_SID(ID));


and then I modified the applicationContext-common-business.xml, replace hsql with mysql
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerD ataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url" value="jdbc:mysql://localhost:3306/springacls" />
<property name="username" value="root" />
<property name="password" value="root" />
</bean>

when I started the tomcat,I got error :
严重: Error listenerStart
how can i solve this problem ?
looking forward for your answer.

immortal_hero
Sep 26th, 2008, 09:06 PM
A full stack trace would be helpful. Please post.

wangl@cmbchina
Sep 26th, 2008, 09:15 PM
hi
I configured log4j to debug,but no othe infos output.so I thought if some other error happened before spring bean initialized

wangl@cmbchina
Sep 26th, 2008, 10:01 PM
<!--
<bean id="dataSourcePopulator" class="sample.contact.DataSourcePopulator">
<property name="dataSource" ref="dataSource"/>
<property name="mutableAclService" ref="aclService"/>
<property name="platformTransactionManager" ref="transactionManager"/>
</bean>
-->
uncommented this para,it's function is initial hsqldb database.

so the contacts may not apply to mysql db.

continue modified

wangl@cmbchina
Oct 7th, 2008, 04:03 AM
modify JdbcMutableAclService
// private String classIdentityQuery = "call identity()";
// private String sidIdentityQuery = "call identity()";
private String classIdentityQuery = "select max(ID) from acl_class";
private String sidIdentityQuery = "select max(ID) from acl_sid";

Xaer
Oct 7th, 2008, 04:14 AM
modify JdbcMutableAclService
// private String classIdentityQuery = "call identity()";
// private String sidIdentityQuery = "call identity()";
private String classIdentityQuery = "select max(ID) from acl_class";
private String sidIdentityQuery = "select max(ID) from acl_sid";

That sounded like a pretty bad fix. Please check out "select last_insert_id()" at [dev.mysql.com/doc/refman/5.0/en/information-functions.html#function_last-insert-id] :)