Я использую приведенный ниже код для выполнения собственного запроса:
@Entity
@Table(name = "users")
@Getter
@Setter
public class Users{
@Id
@SequenceGenerator(name = "cons_seq", sequenceName = "cons_seq", allocationSize = 100)
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "cons_seq")
@Column(name = "id", nullable = false)
private Long id;
@Column(name = "created_by")
private String created_by;
}
Репозиторий:
@Repository
public interface ProfileRepository extends JpaRepository {
@Query(value = """
INSERT INTO users (id, created_by)
VALUES (nextval('cons_seq'), :createdBy)
""", nativeQuery = true)
void create(@Param("createdBy") String createdBy);
}
.......
public void create(final Profile profile) {
profileRepository.create("test);
}
Я получаю сообщение об ошибке:
Причина: org.postgresql.util.PSQLException: Никакие результаты не возвращены запрос.
Запись добавлена в базу данных, но я получаю сообщение об ошибке. Знаете ли вы, как я могу решить эту проблему?
Файл Gradle:
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.cloud:spring-cloud-starter-openfeign'
implementation 'org.springframework.cloud:spring-cloud-starter-loadbalancer'
implementation 'org.springframework.retry:spring-retry'
implementation 'org.springframework.boot:spring-boot-starter-validation'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.hibernate.validator:hibernate-validator'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
implementation 'joda-time:joda-time:2.13.0'
implementation 'commons-io:commons-io:2.17.0'
implementation 'org.apache.commons:commons-lang3'
implementation 'org.apache.commons:commons-collections4:4.4'
implementation 'org.json:json:20231013'
implementation 'org.springframework.boot:spring-boot-starter-hateoas'
implementation 'org.springframework.security:spring-security-core'
implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'org.springframework.boot:spring-boot-starter-oauth2-resource-server'
implementation 'commons-beanutils:commons-beanutils:1.9.4'
implementation 'commons-validator:commons-validator:1.9.0'
implementation 'ma.glasnost.orika:orika-core:1.5.4'
implementation 'com.nimbusds:nimbus-jose-jwt:9.41.2'
implementation 'org.postgresql:postgresql'
implementation 'org.liquibase:liquibase-core'
implementation 'com.google.guava:guava:33.3.1-jre'
implementation 'org.springframework.cloud:spring-cloud-starter-bootstrap'
annotationProcessor 'org.springframework.boot:spring-boot-
compileOnly 'org.projectlombok:lombok:1.18.34'
annotationProcessor 'org.projectlombok:lombok:1.18.34'
testCompileOnly 'org.projectlombok:lombok:1.18.34'
testAnnotationProcessor 'org.projectlombok:lombok:1.18.34'
implementation 'org.springdoc:springdoc-openapi-ui:1.8.0'
testImplementation 'org.junit.jupiter:junit-jupiter-api'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine'
}
dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
}
}
Подробнее здесь: https://stackoverflow.com/questions/791 ... ry-when-sq
Org.postgresql.util.PSQLException: запрос не вернул никаких результатов при вставке SQL ⇐ JAVA
Программисты JAVA общаются здесь
1729857289
Anonymous
Я использую приведенный ниже код для выполнения собственного запроса:
@Entity
@Table(name = "users")
@Getter
@Setter
public class Users{
@Id
@SequenceGenerator(name = "cons_seq", sequenceName = "cons_seq", allocationSize = 100)
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "cons_seq")
@Column(name = "id", nullable = false)
private Long id;
@Column(name = "created_by")
private String created_by;
}
Репозиторий:
@Repository
public interface ProfileRepository extends JpaRepository {
@Query(value = """
INSERT INTO users (id, created_by)
VALUES (nextval('cons_seq'), :createdBy)
""", nativeQuery = true)
void create(@Param("createdBy") String createdBy);
}
.......
public void create(final Profile profile) {
profileRepository.create("test);
}
Я получаю сообщение об ошибке:
Причина: org.postgresql.util.PSQLException: Никакие результаты не возвращены запрос.
Запись добавлена в базу данных, но я получаю сообщение об ошибке. Знаете ли вы, как я могу решить эту проблему?
[b]Файл Gradle:[/b]
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.cloud:spring-cloud-starter-openfeign'
implementation 'org.springframework.cloud:spring-cloud-starter-loadbalancer'
implementation 'org.springframework.retry:spring-retry'
implementation 'org.springframework.boot:spring-boot-starter-validation'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.hibernate.validator:hibernate-validator'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
implementation 'joda-time:joda-time:2.13.0'
implementation 'commons-io:commons-io:2.17.0'
implementation 'org.apache.commons:commons-lang3'
implementation 'org.apache.commons:commons-collections4:4.4'
implementation 'org.json:json:20231013'
implementation 'org.springframework.boot:spring-boot-starter-hateoas'
implementation 'org.springframework.security:spring-security-core'
implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'org.springframework.boot:spring-boot-starter-oauth2-resource-server'
implementation 'commons-beanutils:commons-beanutils:1.9.4'
implementation 'commons-validator:commons-validator:1.9.0'
implementation 'ma.glasnost.orika:orika-core:1.5.4'
implementation 'com.nimbusds:nimbus-jose-jwt:9.41.2'
implementation 'org.postgresql:postgresql'
implementation 'org.liquibase:liquibase-core'
implementation 'com.google.guava:guava:33.3.1-jre'
implementation 'org.springframework.cloud:spring-cloud-starter-bootstrap'
annotationProcessor 'org.springframework.boot:spring-boot-
compileOnly 'org.projectlombok:lombok:1.18.34'
annotationProcessor 'org.projectlombok:lombok:1.18.34'
testCompileOnly 'org.projectlombok:lombok:1.18.34'
testAnnotationProcessor 'org.projectlombok:lombok:1.18.34'
implementation 'org.springdoc:springdoc-openapi-ui:1.8.0'
testImplementation 'org.junit.jupiter:junit-jupiter-api'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine'
}
dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
}
}
Подробнее здесь: [url]https://stackoverflow.com/questions/79125170/org-postgresql-util-psqlexception-no-results-were-returned-by-the-query-when-sq[/url]
Ответить
1 сообщение
• Страница 1 из 1
Перейти
- Кемерово-IT
- ↳ Javascript
- ↳ C#
- ↳ JAVA
- ↳ Elasticsearch aggregation
- ↳ Python
- ↳ Php
- ↳ Android
- ↳ Html
- ↳ Jquery
- ↳ C++
- ↳ IOS
- ↳ CSS
- ↳ Excel
- ↳ Linux
- ↳ Apache
- ↳ MySql
- Детский мир
- Для души
- ↳ Музыкальные инструменты даром
- ↳ Печатная продукция даром
- Внешняя красота и здоровье
- ↳ Одежда и обувь для взрослых даром
- ↳ Товары для здоровья
- ↳ Физкультура и спорт
- Техника - даром!
- ↳ Автомобилистам
- ↳ Компьютерная техника
- ↳ Плиты: газовые и электрические
- ↳ Холодильники
- ↳ Стиральные машины
- ↳ Телевизоры
- ↳ Телефоны, смартфоны, плашеты
- ↳ Швейные машинки
- ↳ Прочая электроника и техника
- ↳ Фототехника
- Ремонт и интерьер
- ↳ Стройматериалы, инструмент
- ↳ Мебель и предметы интерьера даром
- ↳ Cантехника
- Другие темы
- ↳ Разное даром
- ↳ Давай меняться!
- ↳ Отдам\возьму за копеечку
- ↳ Работа и подработка в Кемерове
- ↳ Давай с тобой поговорим...
Мобильная версия