nearest postcode POJO design question

View: New views
3 Messages — Rating Filter:   Alert me  

nearest postcode POJO design question

by goutham :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello All,

I am implementing a webcomponent which lists the postcodes that are within x miles of my postcodes. The list is already prepared . I am currently looking as to how I should build my java beans and store the data.

As an example I would like the list of postcodes to be stored in my database as below:

tableName: postCode
--------------------
id    postcode someOtherData
1     PC123     blahBlah
2     PC234     blahBlah
3     PC345     blahBlah
4     PC567     blahBlah

tableName:oneMileRadius
-----------------------
id  postCodeId NearestPostCodeId
1      1              2
2      1              4
3      2              5
4      2              10

etc. I have similar tables for 10mile and 50 mile radius respectively.


Please guys could you guide me as to how I should be building my Java Beans

best Regards,
Goutham



Re: nearest postcode POJO design question

by James Sutherland :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

You could have a PostalCode class with a ManyToMany nearPostalCodes to PostalCode.  The one issue is the id in the join table.  If you need this id, and can't remove/autogen it, then you would need an object for the join entries, i.e. PostalCode 1-m to PostalRelationship m-1 to PostalCode.

Re: nearest postcode POJO design question

by goutham :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Yes this is what was confusing me. I would like to have manyToMany relationship but am not sure as to how to use it on the same class.