Change access level to an overridden table method

I’ve created a table that can only have records created in it when a corresponding record is created in another table. Specifically, if a new project is created with a boolean value I’ve added to the projtable set to true, a record is created.

I wish to limit access to the insert method so it will only succeed if it is being called in this capacity. I’ve attempted creating another method called “insertFromProject” and making the insert method private however I am unable to alter the access level or number of parameters on this overwritten field.

How can I get around this?

You can’t set a more restrictive access level to overridden methods and it would be even worse idea trying to make insert() inaccessible. But it doesn’t mean that no solution exists - you should implement validateWrite() to refuse invalid records and you could even override insert() and throw an exception or simply not call super() if not all conditions are met (so you’re sure that the table is consistent even if validateWrite() was not called).

Thanks, I think I was along the right lines but had overcomplicated it. I’d setup a method that performed the validation checks like you have mentioned and if the criteria were met called insert(). I was then going to make insert() private so it could only be called from this other method.

I don’t know why I didn’t just add the validation checks to insert in the first place.