Search Results

Search found 2 results on 1 pages for 'davea'.

Page 1/1 | 1 

  • Hibernate many-to-one - bad usage?

    - by DaveA
    Just trying out Hibernate (with Annotations) and I'm having problems with my mappings. I have two entity classes, AudioCD and Artist. @Entity public class AudioCD implements CatalogItem { @Id @GeneratedValue(strategy = GenerationType.AUTO) private int id; private String title; @ManyToOne(cascade = { CascadeType.ALL }, optional = false) private Artist artist; .... } @Entity @Table(uniqueConstraints = { @UniqueConstraint(columnNames = { "name" }) }) public class Artist { @Id @GeneratedValue(strategy = GenerationType.AUTO) private int id; @Column(nullable = false) private String name; ..... } I get AudioCD objects from an external source. When I try to persist the AudioCD the Artist gets persisted as well, just like I want to happen. If I try persisting another different CD, but Artist already exists I get errors due to constraint violations. I want Hibernate to recognise that the Artist already exists and shouldn't be inserted again. Can this be done via annotations? Or do I have to manage the persistence of the AudioCD and Artist seperately?

    Read the article

  • Trouble enabling Grails logging

    - by Dave
    I have this logging configuration in my Config.groovy file. This is a development environment, started as such. I have verified the file exists and there are 775 perms on the file, but nothing is getting output to the file. // set per-environment serverURL stem for creating absolute links environments { production { grails.serverURL = "http://www.changeme.com" } development { grails.serverURL = "http://localhost:8080/${appName}" logFilePath = "/Users/davea/Tomcat/logs/log4j.log" } test { grails.serverURL = "http://localhost:8080/${appName}" } } // log4j configuration log4j = { console name:'Appender1', layout:pattern(conversionPattern: '%-4r [%t] %-5p %c %x - %m%n') rollingFile name:'Appender2', maxFileSize:1024 * 1024, file:logFilePath, layout:pattern(conversionPattern: '%-4r [%t] %-5p %c %x - %m%n') root { debug 'Appender1', 'Appender2' } } Can anyone tell what's wrong with my configuration? Thanks, - Dave

    Read the article

1