留言板

Table autoincrement property gets removed

Samita Bhujbal,修改在11 年前。

Table autoincrement property gets removed

Regular Member 帖子: 117 加入日期: 11-7-5 最近的帖子
I am using Liferay 6.0.6. I am working on custom module for membership registration. I am using service builder for dealing with tables.. There are 20 tables involved on this module. I have made each table primary key autoincrement from SQLYog so that when data gets added in table it increments primary key automatically.
But sometimes this autoincrement property gets removed automatically. Also we have applied unique index to one table for one column. That also gets deleted automatically sometimes.
What Can be the reason? Is it due to I have set cron job on server which takes daily backup of database ? Or it may due to uploading the updated build on server??
thumbnail
Bart Simpson,修改在11 年前。

RE: Table autoincrement property gets removed

Liferay Master 帖子: 522 加入日期: 11-8-29 最近的帖子
Each time you deploy with change in the service.xml Liferay will check for any changes and update the tables .
I have made each table primary key autoincrement from SQLYog

I don't understand why you did this and not do it the way liferay does it? (CounterService)
Samita Bhujbal,修改在11 年前。

RE: Table autoincrement property gets removed

Regular Member 帖子: 117 加入日期: 11-7-5 最近的帖子
I did it. But CounterLocalServiceUtil generates duplicate primaryid sometimes. Hence I changed to this.
Siby Mathew,修改在11 年前。

RE: Table autoincrement property gets removed

Expert 帖子: 268 加入日期: 11-3-4 最近的帖子
Have you implemented like this :
CounterLocalServceUtil.increment(yourEntity.class.getName());
Samita Bhujbal,修改在11 年前。

RE: Table autoincrement property gets removed

Regular Member 帖子: 117 加入日期: 11-7-5 最近的帖子
yes I did this only. But sometimes it was creating duplicate primaryID. So I removed this from code and set primaryId column as autoincremented in Mysql.
thumbnail
Sampsa Sohlman,修改在11 年前。

RE: Table autoincrement property gets removed

Regular Member 帖子: 230 加入日期: 07-9-27 最近的帖子
Hi Samita,

Samita Bhujbal:
I did it. But CounterLocalServiceUtil generates duplicate primaryid sometimes. Hence I changed to this.


Can you repeat this behavior and which situation you are getting this?
thumbnail
Jaynil A Bagdai,修改在11 年前。

RE: Table autoincrement property gets removed

Regular Member 帖子: 119 加入日期: 12-3-3 最近的帖子
Hi Samita,

Do avoid these kind of issues use

CounterLocalServceUtil.increment();


Without giving entity name as parameter, this will always return you new and unique key for sure..

hope this helps you.

Thanks,
Jaynil
Samita Bhujbal,修改在11 年前。

RE: Table autoincrement property gets removed

Regular Member 帖子: 117 加入日期: 11-7-5 最近的帖子
But when we want to add entries for specific entity then giving entity name is necessary.