All pastes #291498 Raw Edit

Mine

public text v1 · immutable
#291498 ·published 2006-12-25 08:01 UTC
rendered paste body
	<class name="Song">
		<id name="id" column="id">
			<generator class="native"/>
		</id>
		<property name="name"/>
		<property name="path"/>
		<property name="track"/>
		<property name="weight"/>
		<many-to-one name="album" cascade="save-update" fetch="join"></many-to-one>
		<many-to-one name="artist" cascade="save-update" fetch="join"></many-to-one>
		<many-to-one name="genre" cascade="save-update" fetch="join"></many-to-one>
	</class>

	<class name="Album">
		<id name="id" column="id">
			<generator class="native"/>
		</id>
		<property name="name" unique="true"></property>
	</class>


org.springframework.dao.DataIntegrityViolationException: could not insert: [us.jyg.freshet.dao.model.Album]; nested exception is org.hibernate.exception.ConstraintViolationException: could not insert: [us.jyg.freshet.dao.model.Album]
Caused by: org.hibernate.exception.ConstraintViolationException: could not insert: [us.jyg.freshet.dao.model.Album]
.....
	at org.springframework.orm.hibernate3.HibernateTemplate.saveOrUpdate(HibernateTemplate.java:676)
	at us.jyg.freshet.dao.util.SongFactory.doHibernate(SongFactory.java:56)




					SongData songData = new SongData(f);
					Album album = new Album(songData.getAlbum());
					Artist artist = new Artist(songData.getArtist());
					Genre genre = new Genre(songData.getGenre());
					Song song = new Song(
							songData.getName(),
							songData.getPath(),
							songData.getTrack(),
							album, artist, genre);
					ht.saveOrUpdate(song);