Org.postgresql.util.PSQLException: запрос не вернул никаких результатов при вставке SQLJAVA

Программисты JAVA общаются здесь
Ответить
Anonymous
 Org.postgresql.util.PSQLException: запрос не вернул никаких результатов при вставке SQL

Сообщение 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: Никакие результаты не возвращены запрос.

Запись добавлена ​​в базу данных, но я получаю сообщение об ошибке. Знаете ли вы, как я могу решить эту проблему?
Файл 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
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «JAVA»