java - Schema 'SA' does not exist and dropping table -
i using spring boot create courses , topics database. having trouble bunch of errors showed once made changes courses classes. not sure what's wrong. here error messages:
error 1136 --- [ main] org.hibernate.tool.hbm2ddl.schemaexport : hhh000389: unsuccessful: alter table course drop constraint fkokaxyfpv8p583w8yspapfb2ar error 1136 --- [ main] org.hibernate.tool.hbm2ddl.schemaexport : schema 'sa' not exist error 1136 --- [ main] org.hibernate.tool.hbm2ddl.schemaexport : hhh000389: unsuccessful: drop table course error 1136 --- [ main] org.hibernate.tool.hbm2ddl.schemaexport : schema 'sa' not exist error 1136 --- [ main] org.hibernate.tool.hbm2ddl.schemaexport : hhh000389: unsuccessful: drop table topic error 1136 --- [ main] org.hibernate.tool.hbm2ddl.schemaexport : schema 'sa' not exist warn 1136 --- [ main] o.h.engine.jdbc.spi.sqlexceptionhelper : sql warning code: 10000, sqlstate: 01j01 warn 1136 --- [ main] o.h.engine.jdbc.spi.sqlexceptionhelper : database 'memory:testdb' not created, connection made existing database instead.
also, here course code, topics code alright think having trouble this. using internal database.
package ...
@entity public class course { // here generate constructors , getters/setters @id private string id; private string name; private string description; @manytoone private topic topic; //use tie class topic class, make easier user public topic gettopic() { return topic; } public void settopic(topic topic) { this.topic = topic; } public course() { } public course(string id, string name, string description, string topicid) { super(); this.id = id; name = name; this.description = description; this.topic = new topic(topicid,"",""); } public string getid() { return id; } public void setid(string id) { this.id = id; } public string getname() { return name; } public void setname(string name) { name = name; } public string getdescription() { return description; } public void setdescription(string description) { this.description = description; } } also controller:
@restcontroller() //makes rest controller, every time build class , add on top of public class coursecontroller { @autowired // marks courseservice needs dependency inj. private courseservice courseservice;// create service need private courseservice variable //getall @requestmapping("/topics/{id}/courses") public list<course> getallcourses(@pathvariable string id){ return courseservice.getallcourses(id); //getallcourses topic id } //get @requestmapping("/topics/{topicid}/courses/{id}") public course getcourse(@pathvariable string id) { return courseservice.getcourse(id); } //post @requestmapping(method = requestmethod.post, value = "/topics/{topicid}/courses") public void addcourse(@requestbody course course, @pathvariable string topicid) { course.settopic(new topic(topicid, "", "")); courseservice.addcourse(course); } //put @requestmapping(method = requestmethod.put, value = "/topics/{topicid}/courses/{id}") public void updatecourse(@requestbody course course, @pathvariable string id, @pathvariable string topicid) { course.settopic(new topic(topicid, "", "")); courseservice.updatecourse(course); } //delete @requestmapping(method = requestmethod.delete, value = "/topics/{topicid}/courses/{id}") public void deletecourse(@pathvariable string id, @pathvariable string topicid) { courseservice.deletecourse(id); } } and service class:
package io.msela.springbootstarter.course; import java.util.arraylist; import java.util.list; import org.springframework.beans.factory.annotation.autowired; import org.springframework.stereotype.service; @service public class courseservice { @autowired // injects courserepository it's initialized private courserepository courserepository; public list<course> getallcourses(string topicid){ //getting not good! list<course> courses = new arraylist<>() ; courserepository.findbytopicid(topicid).foreach(courses::add); return courses; } public course getcourse(string id) { return courserepository.findone(id); } public void addcourse(course course) { courserepository.save(course); //save course database } public void updatecourse(course course) { courserepository.save(course); //save both add , update } public void deletecourse(string id) { courserepository.delete(id); } } edit: here's pom.xml file well
http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0
<groupid>io.msela</groupid> <artifactid>course-api-data</artifactid> <version>0.0.1-snapshot</version> <packaging>jar</packaging> <name>course-api-data</name> <description>course api spring data</description> <parent> <groupid>org.springframework.boot</groupid> <artifactid>spring-boot-starter-parent</artifactid> <version>1.5.4.release</version> <relativepath/> <!-- lookup parent repository --> </parent> <properties> <project.build.sourceencoding>utf-8</project.build.sourceencoding> <project.reporting.outputencoding>utf-8</project.reporting.outputencoding> <java.version>1.8</java.version> </properties> <dependencies> <dependency> <groupid>org.springframework.boot</groupid> <artifactid>spring-boot-starter-data-jpa</artifactid> </dependency> <dependency> <groupid>org.springframework.boot</groupid> <artifactid>spring-boot-starter-web</artifactid> </dependency> <dependency> <groupid>org.apache.derby</groupid> <artifactid>derby</artifactid> <scope>runtime</scope> </dependency> <dependency> <groupid>org.springframework.boot</groupid> <artifactid>spring-boot-starter-test</artifactid> <scope>test</scope> </dependency> </dependencies> <build> <plugins> <plugin> <groupid>org.springframework.boot</groupid> <artifactid>spring-boot-maven-plugin</artifactid> </plugin> </plugins> </build> edit 2
the actual error seems following:
exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.unsatisfieddependencyexception: error creating bean name 'coursecontroller': unsatisfied dependency expressed through field 'courseservice'; nested exception org.springframework.beans.factory.unsatisfieddependencyexception: error creating bean name 'courseservice': unsatisfied dependency expressed through field 'courserepository'; nested exception org.springframework.beans.factory.beancreationexception: error creating bean name 'courserepository': invocation of init method failed; nested exception java.lang.illegalargumentexception: not create query metamodel method public abstract java.util.list io.msela.springbootstarter.course.courserepository.findbyname(java.lang.string)!
Comments
Post a Comment