掲示板

Table autoincrement property gets removed

11年前 に Samita Bhujbal によって更新されました。

Table autoincrement property gets removed

Regular Member 投稿: 117 参加年月日: 11/07/05 最新の投稿
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
11年前 に Bart Simpson によって更新されました。

RE: Table autoincrement property gets removed

Liferay Master 投稿: 522 参加年月日: 11/08/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)
11年前 に Samita Bhujbal によって更新されました。

RE: Table autoincrement property gets removed

Regular Member 投稿: 117 参加年月日: 11/07/05 最新の投稿
I did it. But CounterLocalServiceUtil generates duplicate primaryid sometimes. Hence I changed to this.
11年前 に Siby Mathew によって更新されました。

RE: Table autoincrement property gets removed

Expert 投稿: 268 参加年月日: 11/03/04 最新の投稿
Have you implemented like this :
CounterLocalServceUtil.increment(yourEntity.class.getName());
11年前 に Samita Bhujbal によって更新されました。

RE: Table autoincrement property gets removed

Regular Member 投稿: 117 参加年月日: 11/07/05 最新の投稿
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
11年前 に Sampsa Sohlman によって更新されました。

RE: Table autoincrement property gets removed

Regular Member 投稿: 230 参加年月日: 07/09/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
11年前 に Jaynil A Bagdai によって更新されました。

RE: Table autoincrement property gets removed

Regular Member 投稿: 119 参加年月日: 12/03/03 最新の投稿
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
11年前 に Samita Bhujbal によって更新されました。

RE: Table autoincrement property gets removed

Regular Member 投稿: 117 参加年月日: 11/07/05 最新の投稿
But when we want to add entries for specific entity then giving entity name is necessary.