Code Monkey home page Code Monkey logo

Comments (6)

rbygrave avatar rbygrave commented on July 16, 2024

Ok, I have a feeling I know the problem.

Ebean's "ScalarTypes" are expected to be immutable (like the Joda types
etc) so for a update Ebean is expecting a new instance of SimpleStringProperty
to be set.

I suspect that instead a new string value is set to the SimpleStringProperty
instance (so ebean isn't detecting a changed value).

Hmm, do you have a unit test or main method that you are using to test - I
didn't see one in your project.

On 16 January 2014 20:57, nonameplum [email protected] wrote:

Hi,

At the beginning - It is really hard to find some documentation how to
convert some database types to custom classes.

I'm trying to create javaFX8 bean (observable properties) to work with
Ebean.
So bean looks like this:

@entity
@table(name="something")
public class Something {
@id
private SimpleIntegerProperty id;
private SimpleStringProperty name;

public int getId() {
    return id.get();
}

public SimpleIntegerProperty idProperty() {
    return id;
}

public void setId(int id) {
    this.id.set(id);
}

public String getName() {
    return name.get();
}

public SimpleStringProperty nameProperty() {
    return name;
}

public void setName(String name) {
    this.name.set(name);
}

}

I have created to ScalarTypeConverter classes like this:

public class SimpleIntegerPropertyConverter implements ScalarTypeConverter<SimpleIntegerProperty, Integer> {
@OverRide
public SimpleIntegerProperty getNullValue() {
return null;
}

@Override
public SimpleIntegerProperty wrapValue(Integer integer) {
    return new SimpleIntegerProperty(integer);
}

@Override
public Integer unwrapValue(SimpleIntegerProperty simpleIntegerProperty) {
    return simpleIntegerProperty.getValue();
}

}

public class SimpleStringPropertyConverter implements ScalarTypeConverter<SimpleStringProperty, String> {
@OverRide
public SimpleStringProperty getNullValue() {
return null;
}

@Override
public SimpleStringProperty wrapValue(String s) {
    return new SimpleStringProperty(s);
}

@Override
public String unwrapValue(SimpleStringProperty simpleStringProperty) {
    return simpleStringProperty.getValue();
}

}

This works when I'm reading from database. But save, update is not
working. I found that old values is always null. Maybe I'm doing something
wrong or this is bug?

You can find maven project on github where I'm testing that
https://github.com/nonameplum/appFx


Reply to this email directly or view it on GitHubhttps://github.com//issues/69
.

from ebean.

nonameplum avatar nonameplum commented on July 16, 2024

If this working that way you have right - Ebean will not detect changes.
I wrote simple code to test Ebean update
You can find it now here: https://github.com/nonameplum/appFx/blob/master/src/main/java/appFx/controllers/TestController.java

In method makeEbeanTest. In comments you can see what happen when code is run.

from ebean.

rbygrave avatar rbygrave commented on July 16, 2024

Yes, that isn't going to work in that Ebean isn't going to detect changed
values etc.

Hmm, it might work on the next release though. I'm changing the enhancement
and the way update works. Assuming you don't care about 'partial objects /
partially loaded beans' (all the properties on your beans are considered
loaded).

On 17 January 2014 00:47, nonameplum [email protected] wrote:

If this working that way you have right - Ebean will not detect changes.
I wrote simple code to test Ebean update
You can find it now here:
https://github.com/nonameplum/appFx/blob/master/src/main/java/appFx/controllers/TestController.java

In method makeEbeanTest. In comments you can see what happen when code is
run.


Reply to this email directly or view it on GitHubhttps://github.com//issues/69#issuecomment-32462284
.

from ebean.

nonameplum avatar nonameplum commented on July 16, 2024

Thanks for your interest. For now only solution that I found to force update is make this:

Ebean.update(something, new HashSet<String>(Arrays.asList("id", "name")));

I don't see this in Ebean class as public, but you can consider to add methods like:

Ebean.forceUpdate(..);

from ebean.

rbygrave avatar rbygrave commented on July 16, 2024

Yes, I don't see a problem with something like forceUpdate(...);

The next major release (release 4.x) has a large refactor of the update internals (insert, update, delete actually). I put that on hold as I need to get another 3.x release out which I'm working on right now. The 3.x release is pretty close now (maybe 1 week) so I'll get that out and look at release 4.x again.

Ideally I don't look at a forceUpdate() method until the 4.x is underway again.

from ebean.

rbygrave avatar rbygrave commented on July 16, 2024

This should be fixed in 4.0.1-RC1 (current master). The stateless update feature has been re-written. Note that 4.x has new enhancement (agent and mavenenhancer version 4.1.0 should be used - these have just been released to maven central).

Ebean version 4.0.1-RC1 will be released very shortly (days).

I'll close this for now. Let me know how you go when you get to try/use v4.x. Thanks, Rob.

from ebean.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.