java - Db fields validation client side -


i automate client side data validation application uses springmvc , hibernate, specially in case of referential integrity constraint violation. simple version of structure of application follows:

db

i have oracle db tables, let's take example

a table document integer primary key doc_key , title field table page foreign key fk_document_id, key pag_key , text "text" field.

orm/application layer

i have 2 (hibernate) entities(document , page) mapping tables. create page need create document before, not possible create page without specifying related doc_key in foreign key field.

web layer

i created form allows user create new document pages. can insert title document , 1 or more pages. trying create page object without specifying document title results in db error because no document specified pages.

example use case

the user tries create page setting contents without specifying document title. client side validator marks title field in red asking user fill it.

question

is possible automatically generate client side validation rules avoid server side call in case entity/object/row i'm trying insert doesn't satisfy fk integrity rule check?

or there tools allow client side validation tool "understand" foreign keys consistency?

i tried jquery wasn't able find way automatically check foreign keys consistency.

edit: *notes on accepted answer* of course there no way know state of db client side without querying or caching client side, knowledge necessary check if key exists , integrity constraint satisfied. accepted answer matches focus of question. should have thought before

is possible automatically generate client side validation rules avoid server side call in case entity/object/row i'm trying insert doesn't satisfy fk integrity rule check?

the answer no..!!

the database can set different foreign key relations mapping , integrity can maintained specifying foreign key relations in mapping class. hibernate not in front end.!!

you can validations using hibernate annotations.but can done in end. hibernate not deal front end.!!

i understand requirement have, hibernate not front end tool. suggest, operations related db communication must stay in end, else makes entry point security freaks. better keep behind service layer.


Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

php - joomla get content in onBeforeCompileHead function -