Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not editable entity fields are zeroed/nullified when entity is edited in web admin #233

Open
servy opened this issue Jul 30, 2015 · 5 comments

Comments

@servy
Copy link
Contributor

servy commented Jul 30, 2015

If an entity has a persistable field that should not be changed via admin interface (so the field is hidden in formView) that field is zeroed after editing the entity. Sample entity:

@Entity
@Table(name = "test_items")
public class TestItem {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @Column(name = "text")
    private String text;

    @Column(name = "counter")
    private int counter = 42;

    // getters and setters omitted for brevity
}

Sample administration configuration:

public class TestItemAdministration extends AdministrationConfiguration<TestItem> {
    @Override
    public FieldSetConfigurationUnit formView(PersistentFieldSetConfigurationUnitBuilder fragmentBuilder) {
        // counter field is not editable via admin interface
        return fragmentBuilder
                .field("text").editor(Editors.wysiwyg())
                .build();
    }
}

Creating an entity works as expected with counter field value of 42. Editing the entity (changing text) and saving leads to counter field being set to zero. Expected behavior for the counter field is to preserve its value after editing the entity.

Same problem exists for object types (expirienced it with DateTime). Object fields are set to null after editing an entity if those fields are not shown in the formView. If database has NOT NULL constraint on the field saving changes fails with an exception.

First revision affected by this issue is a9d44ef. Earlier revisions work fine.

@agustisanchez
Copy link

Yes, this is a big bug as all my entities have a creationDate field that I don't want to show in the form view and which should not be set to null (or overridden with any value) during update operations.

Currently, all update operations fail in my app because of that.

@agustisanchez
Copy link

Related to #150 .

Apparently it was fixed in 1.1.0.RELEASE. But it's still there in 1.0.1.RELEASE and 1.2.0.RC1.

@anegrin
Copy link
Contributor

anegrin commented Oct 21, 2015

it does not look like a light-admin issue but a spring-data/jackson issue.

i solved this by annotating my entities and/or mapped superclass with

@JsonIgnoreProperties({"createdAt", "createdBy", "updatedAt", "updatedBy"})

where "createdAt", "createdBy", "updatedAt", "updatedBy" are my auditing properties, no present in the form but stored in the db

@schloemi
Copy link

@JsonIgnoreProperties({"createdAt", "createdBy", "updatedAt", "updatedBy"}) is not really an option, cause fields will also not available in listView oder quickView.

Will this be fixed in future releases?

@Intelligent2013
Copy link

I found that this issue (Not editable entity fields are zeroed/nullified when entity is edited in web admin) was fixed the version 1.1.0.BUILD-SNAPSHOT 20140917.172357-18. But the version 20150530.133354-43 has this issue again. I would like to use more newer version than 20140917. Could you inform me, in what last version (i.e. before 20150530.133354-43) the issue still fixed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants