Форум программистов, компьютерный форум CyberForum.ru

Java и базы данных

Войти
Регистрация
Восстановить пароль
 
kostrorod
39 / 28 / 6
Регистрация: 14.04.2012
Сообщений: 244
#1

PostgreSQL Не проходит тест удаления Entity из БД по id - Java БД

01.12.2016, 15:33. Просмотров 320. Ответов 6

Не проходит тест удаления Entity из базы данных (где данные существуют, тест get проходит) по id

Entity:
Кликните здесь для просмотра всего текста
Java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
@Entity
@Table(name = "lightShows")
public class LightShow  extends  NamedEntity {
 
    /**
     * key - объект эффект
     * value - позиция начала эффекта в милисекундах
     */
    @ElementCollection
    @CollectionTable(name="lightShow_effect_time_start",joinColumns = @JoinColumn(name = "lightShow_id"))
    @MapKeyJoinColumn(name="effect_id")
    @Column(name="time")
    private Map<Effect, Integer> effects;
 
    @OneToMany
    @ElementCollection
    @CollectionTable(name="lightShow_devices",joinColumns = @JoinColumn(name = "lightShow_id"))
    @JoinColumn(name="device_id")
    private List<Device> devices;
 
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "user_id", nullable = false)
    private User user;
 
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "remix_user_id", nullable = false)
    private User remixUser;
 
    @Column(name = "time", nullable = false)
    private int time; // в милисекундах продолжительность шоу
 
    @OneToOne
    @JoinColumn(name = "audio_id", nullable = false)
    private Audio audio;
 
    public LightShow() {
    }
 
    public LightShow(Long id, String name, List<Device> devices, User user) {
        super(id, name);
        this.devices = devices;
        this.user = user;
    }

тест
Кликните здесь для просмотра всего текста
Java
1
2
3
4
@Test
    public void delete() throws Exception {
        lightShowService.delete(23l);
    }

ошибка
Кликните здесь для просмотра всего текста
Java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
15:17:35.270 [main] DEBUG org.hibernate.engine.transaction.internal.TransactionImpl - begin
15:17:35.270 [main] DEBUG org.springframework.jdbc.datasource.DriverManagerDataSource - Creating new JDBC DriverManager Connection to [jdbc:postgresql://localhost:5432/electronSun]
15:17:35.303 [main] DEBUG org.springframework.orm.jpa.JpaTransactionManager - Exposing JPA transaction as JDBC transaction [org.springframework.orm.jpa.vendor.HibernateJpaDialect$HibernateConnectionHandle@173f1614]
15:17:35.313 [main] DEBUG org.hibernate.SQL - select effect0_.id as id1_4_0_, effect0_.name as name2_4_0_, effect0_.appearance as appearan3_4_0_, effect0_.attenuation as attenuat4_4_0_, effect0_.commonTime as commonTi5_4_0_, effect0_.lightShow_id as lightSho6_4_0_, lightshow1_.id as id1_8_1_, lightshow1_.name as name2_8_1_, lightshow1_.audio_id as audio_id4_8_1_, lightshow1_.remix_user_id as remix_us5_8_1_, lightshow1_.time as time3_8_1_, lightshow1_.user_id as user_id6_8_1_, audio2_.id as id1_0_2_, audio2_.name as name2_0_2_, audio2_.path as path3_0_2_ from effects effect0_ inner join lightShows lightshow1_ on effect0_.lightShow_id=lightshow1_.id inner join audios audio2_ on lightshow1_.audio_id=audio2_.id where effect0_.id=?
Hibernate: select effect0_.id as id1_4_0_, effect0_.name as name2_4_0_, effect0_.appearance as appearan3_4_0_, effect0_.attenuation as attenuat4_4_0_, effect0_.commonTime as commonTi5_4_0_, effect0_.lightShow_id as lightSho6_4_0_, lightshow1_.id as id1_8_1_, lightshow1_.name as name2_8_1_, lightshow1_.audio_id as audio_id4_8_1_, lightshow1_.remix_user_id as remix_us5_8_1_, lightshow1_.time as time3_8_1_, lightshow1_.user_id as user_id6_8_1_, audio2_.id as id1_0_2_, audio2_.name as name2_0_2_, audio2_.path as path3_0_2_ from effects effect0_ inner join lightShows lightshow1_ on effect0_.lightShow_id=lightshow1_.id inner join audios audio2_ on lightshow1_.audio_id=audio2_.id where effect0_.id=?
15:17:35.344 [main] DEBUG org.hibernate.resource.jdbc.internal.ResourceRegistryStandardImpl - HHH000387: ResultSet's statement was not registered
15:17:35.344 [main] DEBUG org.hibernate.loader.entity.plan.AbstractLoadPlanBasedEntityLoader - Done entity load : model.Effect#25
15:17:35.344 [main] DEBUG org.springframework.orm.jpa.JpaTransactionManager - Initiating transaction rollback
15:17:35.344 [main] DEBUG org.springframework.orm.jpa.JpaTransactionManager - Rolling back JPA transaction on EntityManager [SessionImpl(PersistenceContext[entityKeys=[],collectionKeys=[]];ActionQueue[insertions=ExecutableList{size=0} updates=ExecutableList{size=0} deletions=ExecutableList{size=0} orphanRemovals=ExecutableList{size=0} collectionCreations=ExecutableList{size=0} collectionRemovals=ExecutableList{size=0} collectionUpdates=ExecutableList{size=0} collectionQueuedOps=ExecutableList{size=0} unresolvedInsertDependencies=null])]
15:17:35.344 [main] DEBUG org.hibernate.engine.transaction.internal.TransactionImpl - rolling back
15:17:35.346 [main] DEBUG org.springframework.orm.jpa.JpaTransactionManager - Closing JPA EntityManager [SessionImpl(PersistenceContext[entityKeys=[],collectionKeys=[]];ActionQueue[insertions=ExecutableList{size=0} updates=ExecutableList{size=0} deletions=ExecutableList{size=0} orphanRemovals=ExecutableList{size=0} collectionCreations=ExecutableList{size=0} collectionRemovals=ExecutableList{size=0} collectionUpdates=ExecutableList{size=0} collectionQueuedOps=ExecutableList{size=0} unresolvedInsertDependencies=null])] after transaction
15:17:35.346 [main] DEBUG org.springframework.orm.jpa.EntityManagerFactoryUtils - Closing JPA EntityManager
15:17:35.347 [main] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Returning cached instance of singleton bean 'emf'
15:17:35.349 [main] DEBUG org.springframework.test.context.support.AbstractDirtiesContextTestExecutionListener - After test method: context [DefaultTestContext@64bfbc86 testClass = EffectServiceTest, testInstance = service.EffectServiceTest@544fe44c, testMethod = delete@EffectServiceTest, testException = org.springframework.dao.EmptyResultDataAccessException: No class model.Effect entity with id 25 exists!, mergedContextConfiguration = [MergedContextConfiguration@64bf3bbf testClass = EffectServiceTest, locations = '{classpath:spring/spring-config.xml, classpath:spring/spring-mvc.xml}', classes = '{}', contextInitializerClasses = '[]', activeProfiles = '{}', propertySourceLocations = '{}', propertySourceProperties = '{}', contextCustomizers = set[[empty]], contextLoader = 'org.springframework.test.context.support.DelegatingSmartContextLoader', parent = [null]]], class annotated with @DirtiesContext [false] with mode [null], method annotated with @DirtiesContext [false] with mode [null].
 
org.springframework.dao.EmptyResultDataAccessException: No class model.Effect entity with id 25 exists!
 
    at org.springframework.data.jpa.repository.support.SimpleJpaRepository.delete(SimpleJpaRepository.java:152)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.executeMethodOn(RepositoryFactorySupport.java:503)
    at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.doInvoke(RepositoryFactorySupport.java:488)
    at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:460)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    at org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:61)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99)
    at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:280)
    at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:136)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    at org.springframework.data.jpa.repository.support.CrudMethodMetadataPostProcessor$CrudMethodMetadataPopulatingMethodInterceptor.invoke(CrudMethodMetadataPostProcessor.java:133)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:213)
    at com.sun.proxy.$Proxy54.delete(Unknown Source)
    at repository.datajpa.DataJpaEffectRepositoryImpl.delete(DataJpaEffectRepositoryImpl.java:37)
    at service.EffectServiceImpl.delete(EffectServiceImpl.java:42)
    at service.EffectServiceTest.delete(EffectServiceTest.java:56)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
    at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:75)
    at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:86)
    at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:84)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:252)
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:94)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
    at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
    at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:191)
    at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
    at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:51)
    at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:237)
    at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)
После регистрации реклама в сообщениях будет скрыта и будут доступны все возможности форума.
kostrorod
39 / 28 / 6
Регистрация: 14.04.2012
Сообщений: 244
02.12.2016, 20:20  [ТС]     PostgreSQL Не проходит тест удаления Entity из БД по id #2
лог с Trace об ошибке
Кликните здесь для просмотра всего текста
Java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
DEBUG TransactionImpl [TransactionImpl.java:55] begin
TRACE AbstractLogicalConnectionImplementor [AbstractLogicalConnectionImplementor.java:65] Preparing to begin transaction via JDBC Connection.setAutoCommit(false)
TRACE AbstractLogicalConnectionImplementor [AbstractLogicalConnectionImplementor.java:68] Transaction begun via JDBC Connection.setAutoCommit(false)
TRACE JdbcResourceLocalTransactionCoordinatorImpl [JdbcResourceLocalTransactionCoordinatorImpl.java:140] ResourceLocalTransactionCoordinatorImpl#afterBeginCallback
TRACE DefaultLoadEventListener [DefaultLoadEventListener.java:254] Loading entity: [model.LightShow#23]
TRACE DefaultLoadEventListener [DefaultLoadEventListener.java:435] Attempting to resolve: [model.LightShow#23]
TRACE DefaultLoadEventListener [DefaultLoadEventListener.java:473] Object not resolved in any cache: [model.LightShow#23]
TRACE AbstractEntityPersister [AbstractEntityPersister.java:4000] Fetching entity: [model.LightShow#23]
DEBUG SQL [SqlStatementLogger.java:92] 
    select
        lightshow0_.id as id1_8_0_,
        lightshow0_.name as name2_8_0_,
        lightshow0_.audio_id as audio_id4_8_0_,
        lightshow0_.remix_user_id as remix_us5_8_0_,
        lightshow0_.time as time3_8_0_,
        lightshow0_.user_id as user_id6_8_0_,
        audio1_.id as id1_0_1_,
        audio1_.name as name2_0_1_,
        audio1_.path as path3_0_1_ 
    from
        lightShows lightshow0_ 
    inner join
        audios audio1_ 
            on lightshow0_.audio_id=audio1_.id 
    where
        lightshow0_.id=?
Hibernate: 
    select
        lightshow0_.id as id1_8_0_,
        lightshow0_.name as name2_8_0_,
        lightshow0_.audio_id as audio_id4_8_0_,
        lightshow0_.remix_user_id as remix_us5_8_0_,
        lightshow0_.time as time3_8_0_,
        lightshow0_.user_id as user_id6_8_0_,
        audio1_.id as id1_0_1_,
        audio1_.name as name2_0_1_,
        audio1_.path as path3_0_1_ 
    from
        lightShows lightshow0_ 
    inner join
        audios audio1_ 
            on lightshow0_.audio_id=audio1_.id 
    where
        lightshow0_.id=?
TRACE ResourceRegistryStandardImpl [ResourceRegistryStandardImpl.java:55] Registering statement [select lightshow0_.id as id1_8_0_, lightshow0_.name as name2_8_0_, lightshow0_.audio_id as audio_id4_8_0_, lightshow0_.remix_user_id as remix_us5_8_0_, lightshow0_.time as time3_8_0_, lightshow0_.user_id as user_id6_8_0_, audio1_.id as id1_0_1_, audio1_.name as name2_0_1_, audio1_.path as path3_0_1_ from lightShows lightshow0_ inner join audios audio1_ on lightshow0_.audio_id=audio1_.id where lightshow0_.id=?]
TRACE JdbcCoordinatorImpl [JdbcCoordinatorImpl.java:333] Registering last query statement [select lightshow0_.id as id1_8_0_, lightshow0_.name as name2_8_0_, lightshow0_.audio_id as audio_id4_8_0_, lightshow0_.remix_user_id as remix_us5_8_0_, lightshow0_.time as time3_8_0_, lightshow0_.user_id as user_id6_8_0_, audio1_.id as id1_0_1_, audio1_.name as name2_0_1_, audio1_.path as path3_0_1_ from lightShows lightshow0_ inner join audios audio1_ on lightshow0_.audio_id=audio1_.id where lightshow0_.id=?]
TRACE BasicBinder [BasicBinder.java:65] binding parameter [1] as [BIGINT] - [23]
TRACE AbstractLoadPlanBasedLoader [AbstractLoadPlanBasedLoader.java:287] Bound [2] parameters total
TRACE ResourceRegistryStandardImpl [ResourceRegistryStandardImpl.java:182] Registering result set [org.postgresql.jdbc.PgResultSet@186d8a71]
TRACE ResultSetProcessorImpl [ResultSetProcessorImpl.java:117] Processing result set
TRACE ResultSetProcessorImpl [ResultSetProcessorImpl.java:131] Done processing result set (0 rows)
TRACE AbstractRowReader [AbstractRowReader.java:231] Total objects hydrated: 0
TRACE ResultSetProcessingContextImpl [ResultSetProcessingContextImpl.java:330] Skipping create subselects because there are fewer than 2 results, so query by key is more efficient.
TRACE ResourceRegistryStandardImpl [ResourceRegistryStandardImpl.java:91] Releasing result set [org.postgresql.jdbc.PgResultSet@186d8a71]
TRACE ResourceRegistryStandardImpl [ResourceRegistryStandardImpl.java:132] Closing result set [org.postgresql.jdbc.PgResultSet@186d8a71]
TRACE ResourceRegistryStandardImpl [ResourceRegistryStandardImpl.java:68] Releasing statement [select lightshow0_.id as id1_8_0_, lightshow0_.name as name2_8_0_, lightshow0_.audio_id as audio_id4_8_0_, lightshow0_.remix_user_id as remix_us5_8_0_, lightshow0_.time as time3_8_0_, lightshow0_.user_id as user_id6_8_0_, audio1_.id as id1_0_1_, audio1_.name as name2_0_1_, audio1_.path as path3_0_1_ from lightShows lightshow0_ inner join audios audio1_ on lightshow0_.audio_id=audio1_.id where lightshow0_.id=23]
DEBUG ResourceRegistryStandardImpl [ResourceRegistryStandardImpl.java:73] HHH000387: ResultSet's statement was not registered
TRACE ResourceRegistryStandardImpl [ResourceRegistryStandardImpl.java:148] Closing prepared statement [select lightshow0_.id as id1_8_0_, lightshow0_.name as name2_8_0_, lightshow0_.audio_id as audio_id4_8_0_, lightshow0_.remix_user_id as remix_us5_8_0_, lightshow0_.time as time3_8_0_, lightshow0_.user_id as user_id6_8_0_, audio1_.id as id1_0_1_, audio1_.name as name2_0_1_, audio1_.path as path3_0_1_ from lightShows lightshow0_ inner join audios audio1_ on lightshow0_.audio_id=audio1_.id where lightshow0_.id=23]
TRACE JdbcCoordinatorImpl [JdbcCoordinatorImpl.java:263] Starting afterQuery statement execution processing [ON_CLOSE]
TRACE StatefulPersistenceContext [StatefulPersistenceContext.java:916] Initializing non-lazy collections
DEBUG AbstractLoadPlanBasedEntityLoader [AbstractLoadPlanBasedEntityLoader.java:189] Done entity load : model.LightShow#23
DEBUG TransactionImpl [TransactionImpl.java:98] rolling back
TRACE AbstractLogicalConnectionImplementor [AbstractLogicalConnectionImplementor.java:113] Preparing to rollback transaction via JDBC Connection.rollback()
TRACE AbstractLogicalConnectionImplementor [AbstractLogicalConnectionImplementor.java:116] Transaction rolled-back via JDBC Connection.rollback()
TRACE AbstractLogicalConnectionImplementor [AbstractLogicalConnectionImplementor.java:53] LogicalConnection#afterTransaction
TRACE ResourceRegistryStandardImpl [ResourceRegistryStandardImpl.java:286] Releasing JDBC resources
TRACE AbstractLogicalConnectionImplementor [AbstractLogicalConnectionImplementor.java:98] re-enabling auto-commit on JDBC Connection afterQuery completion of JDBC-based transaction
TRACE JdbcResourceLocalTransactionCoordinatorImpl [JdbcResourceLocalTransactionCoordinatorImpl.java:162] ResourceLocalTransactionCoordinatorImpl#afterCompletionCallback(false)
TRACE SynchronizationRegistryStandardImpl [DelegatingBasicLogger.java:159] SynchronizationRegistryStandardImpl.notifySynchronizationsAfterTransactionCompletion(5)
TRACE SessionImpl [SessionImpl.java:2394] SessionImpl#afterTransactionCompletion(successful=false, delayed=false)
TRACE SessionImpl [SessionImpl.java:401] Closing session [87d829bb-3de3-4c4b-9afa-02b4b03c50eb]
TRACE JdbcCoordinatorImpl [JdbcCoordinatorImpl.java:173] Closing JDBC container [org.hibernate.engine.jdbc.internal.JdbcCoordinatorImpl@590765c4]
TRACE ResourceRegistryStandardImpl [ResourceRegistryStandardImpl.java:286] Releasing JDBC resources
TRACE LogicalConnectionManagedImpl [LogicalConnectionManagedImpl.java:230] Closing logical connection
TRACE ResourceRegistryStandardImpl [ResourceRegistryStandardImpl.java:286] Releasing JDBC resources
TRACE LogicalConnectionManagedImpl [LogicalConnectionManagedImpl.java:237] Logical connection closed
 
org.springframework.dao.EmptyResultDataAccessException: No class model.LightShow entity with id 23 exists!
 
    at org.springframework.data.jpa.repository.support.SimpleJpaRepository.delete(SimpleJpaRepository.java:152)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.executeMethodOn(RepositoryFactorySupport.java:503)
    at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.doInvoke(RepositoryFactorySupport.java:488)
    at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:460)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    at org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:61)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99)
    at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:280)
    at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:136)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    at org.springframework.data.jpa.repository.support.CrudMethodMetadataPostProcessor$CrudMethodMetadataPopulatingMethodInterceptor.invoke(CrudMethodMetadataPostProcessor.java:133)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:213)
    at com.sun.proxy.$Proxy57.delete(Unknown Source)
    at repository.datajpa.DataJpaLightShowRepositoryImpl.delete(DataJpaLightShowRepositoryImpl.java:36)
    at service.LightShowServiceImpl.delete(LightShowServiceImpl.java:41)
    at service.LightShowServiceTest.delete(LightShowServiceTest.java:60)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
    at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:75)
    at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:86)
    at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:84)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:252)
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:94)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
    at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
    at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:191)
    at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
    at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:51)
    at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:237)
    at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)


Добавлено через 13 минут
полный лог http://pastebin.ru/4JKKeL1e
LeX
230 / 230 / 59
Регистрация: 30.06.2010
Сообщений: 856
03.12.2016, 09:09     PostgreSQL Не проходит тест удаления Entity из БД по id #3
lightShowService.delete(23l);
No class model.LightShow entity with id 23 exists!
У тебя нет в бд записи с id 23
kostrorod
39 / 28 / 6
Регистрация: 14.04.2012
Сообщений: 244
03.12.2016, 09:30  [ТС]     PostgreSQL Не проходит тест удаления Entity из БД по id #4
Цитата Сообщение от LeX BB Посмотреть сообщение
У тебя нет в бд записи с id 23
Запись есть, так как тест get проходит.
LeX
230 / 230 / 59
Регистрация: 30.06.2010
Сообщений: 856
03.12.2016, 10:02     PostgreSQL Не проходит тест удаления Entity из БД по id #5
Приведи полостью класс с тестами и lightShowService
kostrorod
39 / 28 / 6
Регистрация: 14.04.2012
Сообщений: 244
03.12.2016, 11:44  [ТС]     PostgreSQL Не проходит тест удаления Entity из БД по id #6
Добавил строку, как посоветовали (с этой строкой все тесты проваливаются, а без неё только delete )
Java
1
@Sql(scripts = "classpath:db/populateDB.sql", config = @SqlConfig(encoding = "UTF-8"))
теперь выходит другая ошибка
Кликните здесь для просмотра всего текста
Java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
org.springframework.jdbc.datasource.init.ScriptStatementFailedException: Failed to execute SQL script statement #2 of class path resource [db/populateDB.sql]: DELETE FROM products; nested exception is org.postgresql.util.PSQLException: ОШИБКА: UPDATE или DELETE в таблице "products" нарушает ограничение внешнего ключа "devices_product_id_fkey" таблицы "devices"
  Подробности: На ключ (id)=(13) всё ещё есть ссылки в таблице "devices".
 
    at org.springframework.jdbc.datasource.init.ScriptUtils.executeSqlScript(ScriptUtils.java:494)
    at org.springframework.jdbc.datasource.init.ResourceDatabasePopulator.populate(ResourceDatabasePopulator.java:231)
    at org.springframework.jdbc.datasource.init.DatabasePopulatorUtils.execute(DatabasePopulatorUtils.java:48)
    at org.springframework.jdbc.datasource.init.ResourceDatabasePopulator.execute(ResourceDatabasePopulator.java:248)
    at org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener$1.doInTransactionWithoutResult(SqlScriptsTestExecutionListener.java:251)
    at org.springframework.transaction.support.TransactionCallbackWithoutResult.doInTransaction(TransactionCallbackWithoutResult.java:34)
    at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:133)
    at org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener.executeSqlScripts(SqlScriptsTestExecutionListener.java:247)
    at org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener.executeSqlScripts(SqlScriptsTestExecutionListener.java:143)
    at org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener.beforeTestMethod(SqlScriptsTestExecutionListener.java:113)
    at org.springframework.test.context.TestContextManager.beforeTestMethod(TestContextManager.java:269)
    at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74)
    at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:86)
    at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:84)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:252)
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:94)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
    at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
    at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:191)
    at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
    at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:51)
    at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:237)
    at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)
Caused by: org.postgresql.util.PSQLException: ОШИБКА: UPDATE или DELETE в таблице "products" нарушает ограничение внешнего ключа "devices_product_id_fkey" таблицы "devices"
  Подробности: На ключ (id)=(13) всё ещё есть ссылки в таблице "devices".
    at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2458)
    at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2158)
    at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:291)
    at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:432)
    at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:358)
    at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:305)
    at org.postgresql.jdbc.PgStatement.executeCachedSql(PgStatement.java:291)
    at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:269)
    at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:265)
    at org.springframework.jdbc.datasource.init.ScriptUtils.executeSqlScript(ScriptUtils.java:473)
    ... 35 more


class LightShowServiceTest
Кликните здесь для просмотра всего текста
Java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package service;
 
import model.Device;
import model.LightShow;
import model.User;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.annotation.Rollback;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.jdbc.Sql;
import org.springframework.test.context.jdbc.SqlConfig;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.transaction.annotation.Transactional;
 
import java.util.List;
 
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.notNullValue;
import static org.junit.Assert.*;
 
/**
 * Created by Александр on 29.11.2016.
 */
@ContextConfiguration({
        "classpath:spring/spring-config.xml",
        "classpath:spring/spring-mvc.xml"
})
@RunWith(SpringJUnit4ClassRunner.class)
@Sql(scripts = "classpath:db/populateDB.sql", config = @SqlConfig(encoding = "UTF-8"))
public class LightShowServiceTest {
    @Autowired
    private LightShowService lightShowService;
    @Autowired
    private UserService userService;
 
    @Test
    @Transactional
    @Rollback(false) // отмена отката
    public void save() throws Exception {
        User user = userService.get(10l);
        LightShow lightShow = new LightShow(null, "testSave",null, user);
        LightShow created = lightShowService.save(lightShow);
        assertThat(created.getId(), is(notNullValue()));
    }
 
    @Test
    public void get() throws Exception {
        LightShow created = lightShowService.get(23l);
        assertThat(created.getId(), is(notNullValue()));
    }
 
    @Test
    public void getLightShowToUser() throws Exception {
        User user = userService.get(10l);
        List<LightShow> lightShowToUser = lightShowService.getLightShowToUser(user);
        assertThat(lightShowToUser.size() > 0, is(true));
        lightShowToUser.forEach(value -> assertThat(value.getId(), is(notNullValue())));
    }
 
    @Test
    public void delete() throws Exception {
        lightShowService.delete(23l);
    }
 
}
MoreAnswers
Эксперт
37091 / 29110 / 5898
Регистрация: 17.06.2006
Сообщений: 43,301
03.12.2016, 19:14     PostgreSQL Не проходит тест удаления Entity из БД по id
Еще ссылки по теме:
C# Не проходит тест
Java SE Задача не проходит тест
C++ Программа не проходит тест на acmp.ru
C# Entity Framework 6 удаления связанных объектов

Искать еще темы с ответами

Или воспользуйтесь поиском по форуму:
kostrorod
39 / 28 / 6
Регистрация: 14.04.2012
Сообщений: 244
03.12.2016, 19:14  [ТС]     PostgreSQL Не проходит тест удаления Entity из БД по id #7
после добавления delete cascade в таблицы, тесты проходят кроме delete
class LightShowServiceTest
Кликните здесь для просмотра всего текста
Java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package service;
 
import model.Device;
import model.LightShow;
import model.User;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.annotation.Rollback;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.jdbc.Sql;
import org.springframework.test.context.jdbc.SqlConfig;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.transaction.annotation.Transactional;
 
import java.util.List;
 
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.notNullValue;
import static org.junit.Assert.*;
 
/**
 * Created by Александр on 29.11.2016.
 */
@ContextConfiguration({
        "classpath:spring/spring-config.xml",
        "classpath:spring/spring-mvc.xml"
})
@RunWith(SpringJUnit4ClassRunner.class)
@Sql(scripts = "classpath:db/populateDB.sql", config = @SqlConfig(encoding = "UTF-8"))
@Rollback(false)
public class LightShowServiceTest {
    @Autowired
    private LightShowService lightShowService;
    @Autowired
    private UserService userService;
 
    @Test
//    @Transactional
//    @Rollback(false) // отмена отката
    public void save() throws Exception {
        User user = userService.get(10l);
        LightShow lightShow = new LightShow(null, "testSave",null, user);
        LightShow created = lightShowService.save(lightShow);
        assertThat(created.getId(), is(notNullValue()));
    }
 
    @Test
    public void get() throws Exception {
        LightShow created = lightShowService.get(23l);
        assertThat(created.getId(), is(notNullValue()));
    }
 
    @Test
    public void getLightShowToUser() throws Exception {
        User user = userService.get(10l);
        List<LightShow> lightShowToUser = lightShowService.getLightShowToUser(user);
        assertThat(lightShowToUser.size() > 0, is(true));
        lightShowToUser.forEach(value -> assertThat(value.getId(), is(notNullValue())));
    }
 
    @Test
    public void delete() throws Exception {
        lightShowService.delete(23l);
    }
 
}

ошибка
Кликните здесь для просмотра всего текста
Java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
org.springframework.dao.EmptyResultDataAccessException: No class model.LightShow entity with id 23 exists!
 
    at org.springframework.data.jpa.repository.support.SimpleJpaRepository.delete(SimpleJpaRepository.java:152)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.executeMethodOn(RepositoryFactorySupport.java:503)
    at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.doInvoke(RepositoryFactorySupport.java:488)
    at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:460)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    at org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:61)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99)
    at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:280)
    at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:136)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    at org.springframework.data.jpa.repository.support.CrudMethodMetadataPostProcessor$CrudMethodMetadataPopulatingMethodInterceptor.invoke(CrudMethodMetadataPostProcessor.java:133)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:213)
    at com.sun.proxy.$Proxy59.delete(Unknown Source)
    at repository.datajpa.DataJpaLightShowRepositoryImpl.delete(DataJpaLightShowRepositoryImpl.java:36)
    at service.LightShowServiceImpl.delete(LightShowServiceImpl.java:41)
    at service.LightShowServiceTest.delete(LightShowServiceTest.java:64)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
    at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:75)
    at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:86)
    at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:84)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:252)
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:94)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
    at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
    at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:191)
    at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
    at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:51)
    at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:237)
    at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)


Добавлено через 7 минут
Может связи неправильные?
TABLE lightShows
Кликните здесь для просмотра всего текста
SQL
1
2
3
4
5
6
7
8
9
CREATE TABLE lightShows (
  id             int8 PRIMARY KEY DEFAULT NEXTVAL('global_seq'),
  name           VARCHAR NOT NULL,
  user_id        int8 NOT NULL,
  remix_user_id  int8 REFERENCES users (id),
  TIME           INTEGER NOT NULL,
  audio_id       int8 REFERENCES audios (id),
  FOREIGN KEY (user_id) REFERENCES users (id) ON DELETE CASCADE
);

TABLE lightShow_devices
Кликните здесь для просмотра всего текста
SQL
1
2
3
4
5
6
CREATE TABLE lightShow_devices (
  lightShow_id   int8 NOT NULL,
  device_id      int8 NOT NULL,
  FOREIGN KEY (lightShow_id) REFERENCES lightShows (id) ON DELETE CASCADE,
  FOREIGN KEY (device_id) REFERENCES devices (id) ON DELETE CASCADE
);

TABLE lightShow_effect_time_start
Кликните здесь для просмотра всего текста
SQL
1
2
3
4
5
6
7
CREATE TABLE lightShow_effect_time_start (
  lightShow_id   int8 NOT NULL,
  effect_id      int8 NOT NULL,
  TIME           INTEGER NOT NULL,
  FOREIGN KEY (lightShow_id) REFERENCES lightShows (id) ON DELETE CASCADE,
  FOREIGN KEY (effect_id) REFERENCES effects (id) ON DELETE CASCADE
);


Добавлено через 5 часов 58 минут
проблема решилась добавлением lazy к полю
Java
1
2
3
  @OneToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "audio_id", nullable = false)
    private Audio audio;
Хотя почему ошибка говорила о несуществуемом id непонятно.
Yandex
Объявления
03.12.2016, 19:14     PostgreSQL Не проходит тест удаления Entity из БД по id
Ответ Создать тему
Опции темы

КиберФорум - форум программистов, компьютерный форум, программирование
Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Рейтинг@Mail.ru