Fóruns

Início » Liferay Portal » English » 3. Development

Visualização combinada Visão plana Exibição em árvore
Tópicos [ Anterior | Próximo ]
toggle
Priyanka Dhingra
Service Builder: foriegn key, not null constraint
8 de Novembro de 2012 05:22
Resposta

Priyanka Dhingra

Ranking: Liferay Master

Mensagens: 501

Data de entrada: 19 de Dezembro de 2011

Mensagens recentes

I have a requirement to create entities with columns that have
1.foreign key references and
2.some columns that have NOT NULL constraints

Please suggest something
Thanks and Regards
Priyanka Dhingra
David H Nebinger
RE: Service Builder: foriegn key, not null constraint
8 de Novembro de 2012 05:48
Resposta

David H Nebinger

Ranking: Liferay Legend

Mensagens: 7253

Data de entrada: 1 de Setembro de 2006

Mensagens recentes

So create the table manually in your database. Liferay will not define the FK relationships for you, so that must be a manual step.

For the not null thing, you have a couple of choices...

Easiest one is the definition of the column for the entity. If the column type is a primitive, you'll never have a null value so you don't have to worry about nulls (instead they would be zeros).

For the FK verification side, you can either do lookup and fk validation check within the XxxLocalServiceImpl class (overriding the addXxx and updateXxx methods), or you could leave them as-is and implement a solution using a model listener (in the onBefore methods, ensure the column has a valid FK value, throw an exception if it does not).
Priyanka Dhingra
RE: Service Builder: foriegn key, not null constraint
8 de Novembro de 2012 21:37
Resposta

Priyanka Dhingra

Ranking: Liferay Master

Mensagens: 501

Data de entrada: 19 de Dezembro de 2011

Mensagens recentes

Thanks for the solution David. I'll follow it...
I am new to Database emoticon
theres some dilemma related to this that what is the following code representing...is it something related to foriegn key reference
1<column name="tterminal_id" type="Collection" mapping-key="tswitch_id"
2            entity="tswitch" />
Subhash Pavuskar
RE: Service Builder: foriegn key, not null constraint
8 de Novembro de 2012 21:50
Resposta

Subhash Pavuskar

Ranking: Regular Member

Mensagens: 234

Data de entrada: 12 de Março de 2012

Mensagens recentes

@Priyanka :
Hope this Blog may help you to understand !! Click Here
Priyanka Dhingra
RE: Service Builder: foriegn key, not null constraint
8 de Novembro de 2012 21:59
Resposta

Priyanka Dhingra

Ranking: Liferay Master

Mensagens: 501

Data de entrada: 19 de Dezembro de 2011

Mensagens recentes

So does that mean-"Liferay defines the FK relationships for us"??????????????
Subhash Pavuskar
RE: Service Builder: foriegn key, not null constraint
8 de Novembro de 2012 22:30
Resposta

Subhash Pavuskar

Ranking: Regular Member

Mensagens: 234

Data de entrada: 12 de Março de 2012

Mensagens recentes

If you check the database, there really isn't any FK created. service.xml just defines specifies "relationships". If you studied service modelling in service oriented architecture, this is how it is suppose to be to make service autonomous.