Fórumok
Service Builder: foriegn key, not null constraint
Priyanka Dhingra, módosítva 11 év-val korábban
Service Builder: foriegn key, not null constraint
Liferay Master Bejegyzések: 501 Csatlakozás dátuma: 2011.12.20. Legújabb bejegyzések
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
1.foreign key references and
2.some columns that have NOT NULL constraints
Please suggest something
Thanks and Regards
Priyanka Dhingra
David H Nebinger, módosítva 11 év-val korábban
RE: Service Builder: foriegn key, not null constraint
Liferay Legend Bejegyzések: 14919 Csatlakozás dátuma: 2006.09.02. Legújabb bejegyzések
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).
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, módosítva 11 év-val korábban
RE: Service Builder: foriegn key, not null constraint
Liferay Master Bejegyzések: 501 Csatlakozás dátuma: 2011.12.20. Legújabb bejegyzések
Thanks for the solution David. I'll follow it...
I am new to Database
theres some dilemma related to this that what is the following code representing...is it something related to foriegn key reference
I am new to Database
theres some dilemma related to this that what is the following code representing...is it something related to foriegn key reference
<column name="tterminal_id" type="Collection" mapping-key="tswitch_id" entity="tswitch" />
Subhash Pavuskar, módosítva 11 év-val korábban
RE: Service Builder: foriegn key, not null constraint
Regular Member Bejegyzések: 234 Csatlakozás dátuma: 2012.03.13. Legújabb bejegyzések
Priyanka Dhingra, módosítva 11 év-val korábban
RE: Service Builder: foriegn key, not null constraint
Liferay Master Bejegyzések: 501 Csatlakozás dátuma: 2011.12.20. Legújabb bejegyzések
So does that mean-"Liferay defines the FK relationships for us"??????????????
Subhash Pavuskar, módosítva 11 év-val korábban
RE: Service Builder: foriegn key, not null constraint
Regular Member Bejegyzések: 234 Csatlakozás dátuma: 2012.03.13. Legújabb bejegyzések
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.