1

i am developing a RESTFUL API using spring-boot for a future Angular Front-End. i am having this problem with creating my entities into postgres tables.

connectivity with the database was checked and all is fine. using mvn clean install & mvn spring-boot run commands generate normal tomcat deployment without any errors. however no tables are create

here's my code: entity:

@Entity
@Table(name = "questions")
public class Question {
    @Id
    @GeneratedValue(generator = "question_generator")
    @SequenceGenerator(
            name = "question_generator",
            sequenceName = "question_sequence",
            initialValue = 1000
    )
    private Long id;

    @NotBlank
    @Size(min = 3, max = 100)
    private String title;

    @Column(columnDefinition = "text")
    private String description;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public Question() {

    }





}

application.propreties:

# ===============================
# DATABASE CONNECTION
# ===============================

spring.datasource.driver-class-name=org.postgresql.Driver
spring.datasource.url=jdbc:postgresql://localhost:5432/postgres
spring.datasource.username=postgres
spring.datasource.password=postgres

# ===============================
# JPA / HIBERNATE
# ===============================

spring.jpa.show-sql=true
spring.jpa.hibernate.ddl-auto=update
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect


# Fix Postgres JPA Error:
# Method org.postgresql.jdbc.PgConnection.createClob() is not yet implemented.
spring.jpa.properties.hibernate.temp.use_jdbc_metadata_defaults=false

and here's my repo:

import model.Question;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

@Repository
public interface QuestionRepository extends JpaRepository<Question, Long> {
}

2 Answers 2

2

i was able to resolve this issue by changing the entity package and made it visible to the app. now it works perfectly fine. the main package name is: com.testAppBlaBla entities's package should be com.testAppBlaBla.model

otherwise the entity won't be generated.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for the answer! I had the same problem and then, I moved my entity to a subpackage of the package containing the DemoApplication class and it finally worked!
1

Try to change spring.jpa.hibernate.ddl-auto property to create value.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.