Search
Search titles only
By:
Search titles only
By:
Log in
Register
Search
Search titles only
By:
Search titles only
By:
Menu
Install the app
Install
Forums
New posts
All threads
Latest threads
New posts
Trending threads
Trending
Search forums
What's new
New posts
New ads
New profile posts
Latest activity
Free Ads
Latest reviews
Search ads
Members
Current visitors
New profile posts
Search profile posts
Contact us
Latest ads
Pure VPN - Up to 27 Months
vgp
Updated:
Friday at 8:10 AM
එක පැකේජ් එකයි මාසෙටම Unlimited Internet. තාමත් DATA CARD දාන්න සල්ලි වියදම් කරනවද? අඩුම මිලට අපෙන්.
sayuru bandara
Updated:
Tuesday at 12:30 PM
Ad icon
ඉන්ටර්නෙට් එකෙන් හරියටම සල්ලි හොයන්න සහ Success වෙන්න කැමතිද? 🚀 (E-Money & Success Stories)
siri sumana
Updated:
May 30, 2026
Gemini AI PRO 18 months Offer
Hawaka
Updated:
May 27, 2026
Ad icon
koko account
DasunEranga
Updated:
May 27, 2026
Electronics
Vehicles
Property
Search
Reply to thread
Forums
Computers & Internet
Problems and Troubleshooting
HATEOAS Driven REST API Design Help
Get the App
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Message
<blockquote data-quote="හෙනයා" data-source="post: 22754229" data-attributes="member: 510186"><p><span style="color: Blue"><p style="text-align: center"><span style="font-size: 12px">මචන්ලා.. ලොකු උදව්වක් ඕනේ.. HATEOAS එක්ක REST හදද්දී bidirectional relationships manage කරල relation links generate කරගන්න හැටි ගැන පොඩි advice වගයක් ඕනේ.. <img src="/styles/default/xenforo/smilies/default/sorry.gif" class="smilie" loading="lazy" alt=":sorry:" title="Sorry :sorry:" data-shortname=":sorry:" /></span></p></span></p><p style="text-align: center"><span style="color: Blue"><span style="font-size: 12px"></span></p></span></p><p style="text-align: center"><span style="color: Blue"><span style="font-size: 12px">example එකක් විදිහට මේ classes දෙකට bi-direction තියෙනවා කියල හිතුවොත් </span></p></span></p><p style="text-align: center"><span style="color: Blue"><span style="font-size: 12px"></span></span></p><p style="text-align: center"><span style="color: Blue"><span style="font-size: 12px">Student <-----> Batch</p></span></span></p><p style="text-align: center"><span style="color: Blue"><span style="font-size: 12px">Many To One </p></p> <p style="text-align: center"></span></p></span></p><p style="text-align: center"><span style="color: Blue"><span style="font-size: 12px">මම entity class දෙක ලිව්වේ මෙහෙමයි.. </span></p></span></p><p style="text-align: center"><span style="color: Blue"><span style="font-size: 12px"></span></p></span></p><p style="text-align: center"><span style="color: Blue"><span style="font-size: 12px">[PHP]</span></p></span></p><p style="text-align: center"><span style="color: Blue"><span style="font-size: 12px">class Student {</span></p></span></p><p style="text-align: center"><span style="color: Blue"><span style="font-size: 12px"> Long id;</span></p></span></p><p style="text-align: center"><span style="color: Blue"><span style="font-size: 12px"></span></p></span></p><p style="text-align: center"><span style="color: Blue"><span style="font-size: 12px"> @ManyToOne</span></p></span></p><p style="text-align: center"><span style="color: Blue"><span style="font-size: 12px"> Batch batch;</span></p></span></p><p style="text-align: center"><span style="color: Blue"><span style="font-size: 12px">}</span></p></span></p><p style="text-align: center"><span style="color: Blue"><span style="font-size: 12px">[/PHP]</span></p></span></p><p style="text-align: center"><span style="color: Blue"><span style="font-size: 12px"></span></p></span></p><p style="text-align: center"><span style="color: Blue"><span style="font-size: 12px"></span></p></span></p><p style="text-align: center"><span style="color: Blue"><span style="font-size: 12px">[PHP]</span></p></span></p><p style="text-align: center"><span style="color: Blue"><span style="font-size: 12px">class Batch {</span></p></span></p><p style="text-align: center"><span style="color: Blue"><span style="font-size: 12px"> Long id;</span></p></span></p><p style="text-align: center"><span style="color: Blue"><span style="font-size: 12px"></span></p></span></p><p style="text-align: center"><span style="color: Blue"><span style="font-size: 12px"> @OneToMany</span></p></span></p><p style="text-align: center"><span style="color: Blue"><span style="font-size: 12px"> List<Student> students;</span></p></span></p><p style="text-align: center"><span style="color: Blue"><span style="font-size: 12px">}</span></p></span></p><p style="text-align: center"><span style="color: Blue"><span style="font-size: 12px">[/PHP]</span></p></span></p><p style="text-align: center"><span style="color: Blue"><span style="font-size: 12px"></span></p></span></p><p style="text-align: center"><span style="color: Blue"><span style="font-size: 12px">එතකොට මම JSON response එකේ relationship links generate කරද්දී මේ ක්රම දෙකෙන් මොකක්ද කරන්න ඕනේ..? </span></p></span></p><p style="text-align: center"><span style="color: Blue"><span style="font-size: 12px"></span></p></span></p><p style="text-align: center"><span style="color: Blue"><span style="font-size: 12px">1 වෙනි ක්රමය කරනවානම් StudentController class එකේ වෙනම method එකක් (GET) ලියන්න වෙනවා නේද අදාළ student ට අදාළ batch එක ගන්න? <img src="/styles/default/xenforo/smilies/default/confused.gif" class="smilie" loading="lazy" alt=":confused:" title="Confused :confused:" data-shortname=":confused:" /></span></p></span></p><p style="text-align: center"><span style="color: Blue"><span style="font-size: 12px"></span></p></span></p><p style="text-align: center"><span style="color: Blue"><span style="font-size: 12px">2 වෙනි ක්රමයේදී එහෙම ඕනේ වෙන්නේ නෑ නේද? හැබැයි එහෙම කරලා පස්සට maintain කරද්දී තව තව ප්රශ්න එයිද? <img src="/styles/default/xenforo/smilies/default/nerd.gif" class="smilie" loading="lazy" alt=":nerd:" title="Nerd :nerd:" data-shortname=":nerd:" /></span></p></span></p><p style="text-align: center"><span style="color: Blue"><span style="font-size: 12px"></span></p></span></p><p style="text-align: center"><span style="color: Blue"><span style="font-size: 12px">Student Response - Method 1</span></p></span></p><p style="text-align: center"><span style="color: Blue"><span style="font-size: 12px"></span></p></span></p><p style="text-align: center"><span style="color: Blue"><span style="font-size: 12px">[PHP]</span></p></span></p><p style="text-align: center"><span style="color: Blue"><span style="font-size: 12px">"id": "1",</span></p></span></p><p style="text-align: center"><span style="color: Blue"><span style="font-size: 12px">"links": [</span></p></span></p><p style="text-align: center"><span style="color: Blue"><span style="font-size: 12px"> {</span></p></span></p><p style="text-align: center"><span style="color: Blue"><span style="font-size: 12px"> "rel": "self",</span></p></span></p><p style="text-align: center"><span style="color: Blue"><span style="font-size: 12px"> "href": "http://localhost:8080/students/1" </span></p></span></p><p style="text-align: center"><span style="color: Blue"><span style="font-size: 12px"> },</span></p></span></p><p style="text-align: center"><span style="color: Blue"><span style="font-size: 12px"> {</span></p></span></p><p style="text-align: center"><span style="color: Blue"><span style="font-size: 12px"> "rel": "batch",</span></p></span></p><p style="text-align: center"><span style="color: Blue"><span style="font-size: 12px"> "href": "http://localhost:8080/students/1/batches/1" </span></p></span></p><p style="text-align: center"><span style="color: Blue"><span style="font-size: 12px"> }</span></p></span></p><p style="text-align: center"><span style="color: Blue"><span style="font-size: 12px">]</span></p></span></p><p style="text-align: center"><span style="color: Blue"><span style="font-size: 12px">[/PHP]</span></p></span></p><p style="text-align: center"><span style="color: Blue"><span style="font-size: 12px"></span></p></span></p><p style="text-align: center"><span style="color: Blue"><span style="font-size: 12px">Student Response - Method 2</span></p></span></p><p style="text-align: center"><span style="color: Blue"><span style="font-size: 12px"></span></p></span></p><p style="text-align: center"><span style="color: Blue"><span style="font-size: 12px">[PHP]</span></p></span></p><p style="text-align: center"><span style="color: Blue"><span style="font-size: 12px">"id": "1",</span></p></span></p><p style="text-align: center"><span style="color: Blue"><span style="font-size: 12px">"links": [</span></p></span></p><p style="text-align: center"><span style="color: Blue"><span style="font-size: 12px"> {</span></p></span></p><p style="text-align: center"><span style="color: Blue"><span style="font-size: 12px"> "rel": "self",</span></p></span></p><p style="text-align: center"><span style="color: Blue"><span style="font-size: 12px"> "href": "http://localhost:8080/students/1" </span></p></span></p><p style="text-align: center"><span style="color: Blue"><span style="font-size: 12px"> },</span></p></span></p><p style="text-align: center"><span style="color: Blue"><span style="font-size: 12px"> {</span></p></span></p><p style="text-align: center"><span style="color: Blue"><span style="font-size: 12px"> "rel": "batch",</span></p></span></p><p style="text-align: center"><span style="color: Blue"><span style="font-size: 12px"> "href": "http://localhost:8080/batches/1" </span></p></span></p><p style="text-align: center"><span style="color: Blue"><span style="font-size: 12px"> }</span></p></span></p><p style="text-align: center"><span style="color: Blue"><span style="font-size: 12px">]</span></p></span></p><p style="text-align: center"><span style="color: Blue"><span style="font-size: 12px">[/PHP]</span></p></span></p><p style="text-align: center"><span style="color: Blue"><span style="font-size: 12px"></span></p></span></p><p style="text-align: center"><span style="color: Blue"><span style="font-size: 12px">මෙතැනදී batch එක පැත්තෙන් ගත්තොත් එවන්න වෙන්නේ Resource Collection එකක් නෙහ්..(studentList) ? එතකොට අර විදිහට කරන්න බෑ නේද නිකන් student collection url එක එව්වොත් අදාළ batch එකට filter වෙන්නේ නැති නිසා.. <img src="/styles/default/xenforo/smilies/default/confused.gif" class="smilie" loading="lazy" alt=":confused:" title="Confused :confused:" data-shortname=":confused:" /></span></p></span></p><p style="text-align: center"><span style="color: Blue"><span style="font-size: 12px"></span></p></span></p><p style="text-align: center"><span style="color: Blue"><span style="font-size: 12px">Batch Response</span></p></span></p><p style="text-align: center"><span style="color: Blue"><span style="font-size: 12px">[PHP]</span></p></span></p><p style="text-align: center"><span style="color: Blue"><span style="font-size: 12px">"id": "1",</span></p></span></p><p style="text-align: center"><span style="color: Blue"><span style="font-size: 12px">"links": [</span></p></span></p><p style="text-align: center"><span style="color: Blue"><span style="font-size: 12px"> {</span></p></span></p><p style="text-align: center"><span style="color: Blue"><span style="font-size: 12px"> "rel": "self",</span></p></span></p><p style="text-align: center"><span style="color: Blue"><span style="font-size: 12px"> "href": "http://localhost:8080/batches/1" </span></p></span></p><p style="text-align: center"><span style="color: Blue"><span style="font-size: 12px"> },</span></p></span></p><p style="text-align: center"><span style="color: Blue"><span style="font-size: 12px"> {</span></p></span></p><p style="text-align: center"><span style="color: Blue"><span style="font-size: 12px"> "rel": "student",</span></p></span></p><p style="text-align: center"><span style="color: Blue"><span style="font-size: 12px"> "href": "http://localhost:8080/batches/1/students" </span></p></span></p><p style="text-align: center"><span style="color: Blue"><span style="font-size: 12px"> }</span></p></span></p><p style="text-align: center"><span style="color: Blue"><span style="font-size: 12px">]</span></p></span></p><p style="text-align: center"><span style="color: Blue"><span style="font-size: 12px">[/PHP]</span></p></span></p><p style="text-align: center"><span style="color: Blue"><span style="font-size: 12px"></span></p></span></p><p style="text-align: center"><span style="color: Blue"><span style="font-size: 12px">දන්නා කස්ටියගෙන් උදාව්.... <img src="/styles/default/xenforo/smilies/default/sad.gif" class="smilie" loading="lazy" alt=":(" title="Sad :(" data-shortname=":(" /><img src="/styles/default/xenforo/smilies/default/sad.gif" class="smilie" loading="lazy" alt=":(" title="Sad :(" data-shortname=":(" /><img src="/styles/default/xenforo/smilies/default/sad.gif" class="smilie" loading="lazy" alt=":(" title="Sad :(" data-shortname=":(" /></span></p><p></span></p></blockquote><p></p>
[QUOTE="හෙනයා, post: 22754229, member: 510186"] [COLOR="Blue"][CENTER][SIZE="3"]මචන්ලා.. ලොකු උදව්වක් ඕනේ.. HATEOAS එක්ක REST හදද්දී bidirectional relationships manage කරල relation links generate කරගන්න හැටි ගැන පොඩි advice වගයක් ඕනේ.. :sorry: example එකක් විදිහට මේ classes දෙකට bi-direction තියෙනවා කියල හිතුවොත් [CENTER]Student <-----> Batch Many To One [/CENTER] මම entity class දෙක ලිව්වේ මෙහෙමයි.. [PHP] class Student { Long id; @ManyToOne Batch batch; } [/PHP] [PHP] class Batch { Long id; @OneToMany List<Student> students; } [/PHP] එතකොට මම JSON response එකේ relationship links generate කරද්දී මේ ක්රම දෙකෙන් මොකක්ද කරන්න ඕනේ..? 1 වෙනි ක්රමය කරනවානම් StudentController class එකේ වෙනම method එකක් (GET) ලියන්න වෙනවා නේද අදාළ student ට අදාළ batch එක ගන්න? :confused: 2 වෙනි ක්රමයේදී එහෙම ඕනේ වෙන්නේ නෑ නේද? හැබැයි එහෙම කරලා පස්සට maintain කරද්දී තව තව ප්රශ්න එයිද? :nerd: Student Response - Method 1 [PHP] "id": "1", "links": [ { "rel": "self", "href": "http://localhost:8080/students/1" }, { "rel": "batch", "href": "http://localhost:8080/students/1/batches/1" } ] [/PHP] Student Response - Method 2 [PHP] "id": "1", "links": [ { "rel": "self", "href": "http://localhost:8080/students/1" }, { "rel": "batch", "href": "http://localhost:8080/batches/1" } ] [/PHP] මෙතැනදී batch එක පැත්තෙන් ගත්තොත් එවන්න වෙන්නේ Resource Collection එකක් නෙහ්..(studentList) ? එතකොට අර විදිහට කරන්න බෑ නේද නිකන් student collection url එක එව්වොත් අදාළ batch එකට filter වෙන්නේ නැති නිසා.. :confused: Batch Response [PHP] "id": "1", "links": [ { "rel": "self", "href": "http://localhost:8080/batches/1" }, { "rel": "student", "href": "http://localhost:8080/batches/1/students" } ] [/PHP] දන්නා කස්ටියගෙන් උදාව්.... :(:(:([/SIZE][/CENTER][/COLOR] [/QUOTE]
Insert quotes…
Verification
Asuwa dahayen wadi kalama keeyada?
Post reply
Top
Bottom