[JBoss Seam] - seam generate-entities error....
by minamti
This scenario seems to create
create table groups (
group_id integer NOT NULL AUTO_INCREMENT,
group_name VARCHAR(100) NOT NULL,
group_desc VARCHAR(100),
PRIMARY KEY(group_id));
insert into groups (group_id, group_name) values(1, "admin");
insert into groups (group_id, group_name) values(2, "others");
create table user (
user_id integer NOT NULL AUTO_INCREMENT,
group_id NOT NULL DEFAULT 2,
user_name VARCHAR(100),
PRIMARY KEY(user_id),
FOREIGN KEY (group_id) REFERENCES group(group_id) ON UPDATE CASCADE ON DELETE RESTRICT);
I seem to get a
Caused by org.hibernate.PropertyValueException with message: "not-null property references a null or transient value: com.foo.entity.User.groups"
Thanks,
M
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4090380#4090380
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4090380
16Â years, 9Â months
[JBoss Seam] - Re: Semantics of @Name, @DataModelSelection
by jacob.orshalick
"djfjboss" wrote : I had also assumed that the setPid method would be invoked via the edit link and thereby set person to the appropriate entity via the id, but this method isn't even called for me. The fact that the RequestParameter annotation is commented out is a little disconcerting.
The pid attribute will not be set unless you uncomment the @RequestParameter annotation (which will directly inject the value) or add an entry in your pages.xml which will call your set method such as,
| <pages>
| <page view-id="/person.xhtml">
| <param name="pid" value="#{manager.id}"/>
| </page>
| ...
| </pages>
I also do not see where fan is being outjected to the page so I don't know where your id would be coming from. Are you providing a list of persons and then the user can edit a person from the list? If you are looking to achieve a RESTful URL here (which is the only reason I could think of for doing it this way), an easier way to accomplish this would be...
@Stateful
| @Name("manager")
| public class ManagerAction implements Manager {
|
| @RequestParameter
| Long pid;
|
| @In (required=false) @Out (required=false)
| private Person person;
|
| @DataModel
| private List <Person> fans;
|
| @Factory(value="person")
| public void loadPerson(Long pid) {
| if (pid != null) {
| person = (Person) em.find(Person.class, pid);
| } else {
| person = new Person ();
| }
| }
| ...
|
Also note that you will not be in the same conversation when the Person is loaded because you are using a general link <a href ...>. Any conversation state will not be propagated. Hope that helps.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4090375#4090375
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4090375
16Â years, 9Â months
[JBoss Seam] - Re: Entity Injection question
by jacob.orshalick
In the scenario you describe, the only time an entity is going to be automatically created is if it is a named Seam component and it has the annotation @AutoCreate. Is this how your entity is annotated?
...
| @Entity
| @Name("someEntity")
| @AutoCreate
| public class SomeEntity {
| ...
Otherwise you would have to have a factory method somewhere...
@Factory(value="someEntity")
| public SomeEntity initSomeEntity() {
| return new SomeEntity();
| }
You have to specify when Seam should create instances of components.
As far as the following code...
| public void submit() {
| if (someEntity.someProperty != null) {
| log.debug("Entity's Property IS NOT NULL");
| else {
| log.debug("Entity's Property IS NULL");
| }
| }
This code is necessary depending on what you're doing. If you performing validation this could actually be done through <s:validate> or <s:validateAll> and use of @NotNull on your entity attribute. Hope that helps.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4090370#4090370
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4090370
16Â years, 9Â months