Reputation: 1897
I got the code
public static List <Post> getPostForTopic(String topicName) {
List <Post> list = find.where().eq("topic_name",topicName).findList();
return list;
}
SQL evoluation
# --- Created by Ebean DDL
# To stop Ebean DDL generation, remove this comment and start using Evolutions
# --- !Ups
create table post (
text varchar(255))
;
create table topic (
topic_name varchar(255) not null,
constraint pk_topic primary key (topic_name))
;
create sequence topic_seq;
# --- !Downs
SET REFERENTIAL_INTEGRITY FALSE;
drop table if exists post;
drop table if exists topic;
SET REFERENTIAL_INTEGRITY TRUE;
drop sequence if exists topic_seq;
When I run it I have Execution exception:
[PersistenceException: Query threw SQLException:Столбец "TOPIC_NAME" не найден Column "TOPIC_NAME" not found; SQL statement: select t0.text c0 from post t0 where topic_name = ? [42122-158] Bind values:[null] Query was: select t0.text c0 from post t0 where topic_name = ? ]
I and when I type query in my h2 database console like "Select * from topic", I got result that there is no table "TOPIC". Help me to find misstake please
Upvotes: 0
Views: 1458
Reputation: 21564
I think that you used a wrong finder.
I bet you create your find
variable with something looking like this (I actually don't know what type you used as primary key):
public static Finder<XXX,Post> find = new Finder<XXX,Post>(
XXX.class, Post.class
);
whereas you should use:
public static Finder<String,Topic> find = new Finder<String,Topic>(
String.class, Topic.class
);
Upvotes: 2