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

Serial does not work w/ Jackson 2.8.9 #18688

Closed
wdroste opened this issue Sep 21, 2017 · 6 comments
Closed

Serial does not work w/ Jackson 2.8.9 #18688

wdroste opened this issue Sep 21, 2017 · 6 comments

Comments

@wdroste
Copy link

wdroste commented Sep 21, 2017

Is this a question, feature request, or bug report?

Bug report

QUESTION

Have you checked our documentation at https://cockroachlabs.com/docs/stable/? If you could not find an answer there, please consider asking your question in our community forum at https://forum.cockroachlabs.com/, as it would benefit other members of our community.

yes

Prefer live chat? Message our engineers on our Gitter channel at https://gitter.im/cockroachdb/cockroach.

BUG REPORT

  1. Please supply the header (i.e. the first few lines) of your most recent
    log file for each node in your cluster. On most unix-based systems
    running with defaults, this boils down to the output of

    grep -F '[config]' cockroach-data/logs/cockroach.log

    When log files are not available, supply the output of cockroach version
    and all flags/environment variables passed to cockroach start instead.

I170921 14:26:58.485800 1 util/log/clog.go:1013 [config] file created at: 2017/09/21 14:26:58
I170921 14:26:58.485800 1 util/log/clog.go:1013 [config] running on machine: jackburton
I170921 14:26:58.485800 1 util/log/clog.go:1013 [config] binary: CockroachDB CCL v1.0.5 (linux amd64, built 2017/08/24 17:43:46, go1.8.3)
I170921 14:26:58.485800 1 util/log/clog.go:1013 [config] arguments: [cockroach start --insecure --http-port 2800]

  1. Please describe the issue you observed:
  • What did you do?

Libraries
hibernate 5.2.8
postgresql 9.5.1212

Using Spring Data for JPA via Spring Boot 1.5.6
org.springframework.data.repository.CrudRepository.findOne

fails to find a existing row by serial number..

Hibernate log:

Hibernate: select group0_.id as id1_2_0_, group0_.description as descript2_2_0_, group0_.jhi_key as jhi_key3_2_0_, group0_.name as name4_2_0_ from jhi_group group0_ where group0_.id=?

Confirmed from the CLI that I was able to create the record through Spring Data was also able to do findAll through Spring Data however findOne and delete basically anything that used the ID directly was failing..

From the UI database

CREATE TABLE jhi_group (
id INT NOT NULL DEFAULT unique_rowid(),
jhi_key STRING(50) NOT NULL,
name STRING(50) NULL,
description STRING(255) NULL,
CONSTRAINT "primary" PRIMARY KEY (id ASC),
UNIQUE INDEX jhi_group_jhi_key_key (jhi_key ASC),
FAMILY "primary" (id, jhi_key, name, description)
)

My create table command.

CREATE TABLE IF NOT EXISTS usp.jhi_group (
    id          SERIAL PRIMARY KEY,
    jhi_key     VARCHAR (50) UNIQUE NOT NULL,
    name        VARCHAR(50),
    description VARCHAR(255)
)
@wdroste
Copy link
Author

wdroste commented Sep 21, 2017

Figured it out.. something is wrong w/ findAll marshalling

The query to findAll brings back the IDs..
281653276981067780

But in the database the ID is actually..
281653276981067777

@wdroste
Copy link
Author

wdroste commented Sep 21, 2017

Cleared out the database again.. and here's what I found the ID is being rounded up..
281691110485819400

actual

281691110485819393

@wdroste
Copy link
Author

wdroste commented Sep 21, 2017

Its not hibernate or spring data it appears to be Jackson's serializer.. At the point when it gets to the REST Controller its fine.

@wdroste wdroste changed the title Spring Data w/ Hibernate does not work w/ CockroachDB for findOne Serial does not work w/ Jackson 2.8.9 Sep 21, 2017
@wdroste
Copy link
Author

wdroste commented Sep 21, 2017

Turns out the Jackson's outputLong is broken.

@wdroste wdroste closed this as completed Sep 21, 2017
@a-robinson
Copy link
Contributor

Thanks for following up after you tracked the problem down!

@wdroste
Copy link
Author

wdroste commented Sep 22, 2017

No problem.. I dug deeper and did a unit test for Jackson and that wasn't it either.. It turns out that it was Chrome it appears its a issue w/ numbers in JSON and precision.. Chrome is less than 64bit something like 53bit.. and worse it rounds up.. so basically the solution is to treat it as a string coming from a REST api.. so if anyone is curious use

@JsonSerialize(using=ToStringSerializer.class)
public long getId() {
    return id;
}

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

2 participants