5

What is the difference between @Bind and @BindBean in JDBI?

Example code:

@SqlUpdate("insert into myObject (id, name) values (:id, :name)")
int insert(@BindBean MyObject myObject);

@SqlQuery("select id, name from myObject where id = :id")
MyObject findById(@Bind("id") long id);
Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
user4975679
  • 1,461
  • 16
  • 21

1 Answers1

6

From JDBI docs

The @Bind annotation binds a single named argument. If no value is specified for the annotation it will bind the argument to the name it.

and

The @BindBean annotation binds JavaBeans™ properties by name. If no value is given to the annotation the bean properties will be bound directly to their property names. If a value is given, the properties will be prefixed by the value given and a period.

alecswan
  • 3,670
  • 5
  • 25
  • 35