Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Samita Bhujbal
Table autoincrement property gets removed
March 6, 2013 10:47 PM
Answer

Samita Bhujbal

Rank: Regular Member

Posts: 120

Join Date: July 5, 2011

Recent Posts

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??
Bart Simpson
RE: Table autoincrement property gets removed
March 7, 2013 1:20 AM
Answer

Bart Simpson

Rank: Liferay Master

Posts: 523

Join Date: August 29, 2011

Recent Posts

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
RE: Table autoincrement property gets removed
March 7, 2013 2:32 AM
Answer

Samita Bhujbal

Rank: Regular Member

Posts: 120

Join Date: July 5, 2011

Recent Posts

I did it. But CounterLocalServiceUtil generates duplicate primaryid sometimes. Hence I changed to this.
Siby Mathew
RE: Table autoincrement property gets removed
March 7, 2013 5:54 AM
Answer

Siby Mathew

Rank: Expert

Posts: 259

Join Date: March 4, 2011

Recent Posts

Have you implemented like this :
1CounterLocalServceUtil.increment(yourEntity.class.getName());
Sampsa Sohlman
RE: Table autoincrement property gets removed
March 7, 2013 8:19 AM
Answer

Sampsa Sohlman

LIFERAY STAFF

Rank: Regular Member

Posts: 217

Join Date: September 27, 2007

Recent Posts

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?
Jaynil A Bagdai
RE: Table autoincrement property gets removed
March 8, 2013 12:24 AM
Answer

Jaynil A Bagdai

Rank: Regular Member

Posts: 119

Join Date: March 3, 2012

Recent Posts

Hi Samita,

Do avoid these kind of issues use
1
2CounterLocalServceUtil.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
RE: Table autoincrement property gets removed
March 13, 2013 5:56 AM
Answer

Samita Bhujbal

Rank: Regular Member

Posts: 120

Join Date: July 5, 2011

Recent Posts

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.
Samita Bhujbal
RE: Table autoincrement property gets removed
March 13, 2013 5:58 AM
Answer

Samita Bhujbal

Rank: Regular Member

Posts: 120

Join Date: July 5, 2011

Recent Posts

But when we want to add entries for specific entity then giving entity name is necessary.