2010-12-15 3 views
5

: http://www.grails.org/doc/1.0.x/guide/5.%20Object%20Relational%20Mapping%20(GORM).html 다음 (그들은 공항을 belongTo 때문에) 연관된 비행 객체를 삭제합니다 공항의 인스턴스에 delete()를 호출Grails는 domain.delete()를 사용하지 않을 때 계단식 삭제를합니까? Grails의 사이트에서

class Airport { 
String name 
static hasMany = [flights:Flight] 
} 
class Flight { 
String number 
static belongsTo = [airport:Airport] 
} 

. executeUpdate을 사용하여 공항을 삭제했다해도 여전히 항공편을 삭제할 수 있습니까?

감사합니다.

답변

4

아니요. 여기에 간단한 예는 다음과 같습니다

def a0 = new Airport(name: 'Dulles').save() 
def f0 = new Flight(number: '1000', airport: a0).save() 

assert 1 == Airport.count() 
assert 1 == Flight.count() 

Airport.executeUpdate("delete Airport a where a.name = 'Dulles'") 

수익률 (약칭 함) :

쿼리 here의 폭포를 지정할 수있는 기능을 요구하는 해결되지 않은 최대 절전 모드 문제가있다
Caused by: java.sql.SQLException: Integrity constraint violation FKB4318470B2E8D1BA table: FLIGHT in statement [delete from airport where name='Dulles'] 
     at org.hsqldb.jdbc.Util.throwError(Unknown Source) 
     at org.hsqldb.jdbc.jdbcPreparedStatement.executeUpdate(Unknown Source) 
     at org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:102) 
     ... 27 more 

.

이 또한 Grails 메일 링리스트 here에 백업되었습니다.

+0

필요할 경우 hibernate (hibernate.cfg.xml)를 수동으로 구성하여이 문제를 해결할 수있는 방법이있을 수 있습니다. –

관련 문제