0
Good morning.
I have a table that uses auto-relationship, it turns out that not all names entered have parent, but I can not create a name with null parent, there is not be the first that was created, as in the example below.
Example:
id name pai
02016356-ED97-439B-8E78-4200547BD5AC Presidente null
239A0DB8-4282-45E5-B5AE-5A2702576E49 Diretoria Geral 02016356-ED97-439B-8E78-4200547BD5AC
Form code
<form:select path="parent.id">
<form:options items="${parents}" itemValue="id" itemLabel="name" />
</form:select>
The column
pai
is set as default valueNULL
?– Rodrigo Rigotti
I think my failure is time to register, because I have an input field where I will put the name and just below I have a combo to choose the father, however, as this value is coming from the bank it does not have a blank field to register null the father, then the option already comes with an initial value.
– Fernando
Your column is
UNIQUE
? You need this?– Maniero
The column is not Unique.
– Fernando
And because he only accepts one
NULL
? If you don’t demand oneness, you should accept as many as you want.– Maniero
it accepts other values that do not accept null, but this is what I want, that accepts null, I can not put via system, only directly in the bank ...
– Fernando
So maybe the problem is in the application, because if you don’t have the restriction of
UNIQUE
you have to accept, and in fact you say you accept severalNULL
. The problem doesn’t seem to be in the database. Either you explain it better, or you change the question to focus on the application or I don’t know how to help.– Maniero
You can place the DDL (table creation setting) in the body of your question?
– Leonel Sanches da Silva
Post the select mount code to select the parent. I think the problem is in the view and not in the bank. What you want is to allow registration without a father, that’s it?
– Lucas
Lucas, that’s right, the problem is in the view. <form:select path="Parent.id"> <form:options items="${parents}" itemValue="id" itemLabel="name" /> </form:select>
– Fernando
What language are you using?
– Lucas
Java with Spring MVC.
– Fernando