Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] Detecting inconsistent foreign references

Hello Patric,

I don't know whether EL can detect data inconsistency, but even if it does, I wouldn't agree that it's a good idea, because one of the most important tasks of a database is Data Consistency.
So, why don't you just define a foreign key constraint in the database?

Regards, Michael

________________________________________
Von: eclipselink-users-bounces@xxxxxxxxxxx [eclipselink-users-bounces@xxxxxxxxxxx] im Auftrag von Patric Rufflar [Patric@xxxxxxxxxxx]
Gesendet: Mittwoch, 10. Oktober 2012 13:34
An: eclipselink-users@xxxxxxxxxxx
Betreff: [eclipselink-users] Detecting inconsistent foreign references

Hello,

I'd like to know if there's a way to detect/react on a data
inconsistency in eclipselink.

Example:
1. Imagine an entity A which has a ManyToOne mapping to entity B.
2. Imagine a database record for an entity A which contains an invalid
foreign key (there is no primary key for this foreign key in the table
of entity B)
3. The corresponding entity A of such a database record is fetched
(using EntityManager.find()).
4. The reference of the mapping to B is null.

Unfortunately, it's also null when the underlying foreign key is null.
As a result you cannot distinguish between a "real" null foreign key,
and an invalid/inconsistent one.

Is it possible to detect such an inconsistency?

Best regards,
Patric

_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users


Back to the top