<commit_before>package org.codehaus.groovy.grails.orm.hibernate;

import org.codehaus.groovy.grails.commons.*
import org.codehaus.groovy.grails.commons.test.*

class ComponentMappingTests extends AbstractGrailsHibernateTests {

	void testComponentMapping() {
		def personClass = ga.getDomainClass("Person")
		def addressClass = ga.getDomainClass("Address")

		def p = personClass.newInstance()

		p.name = "<NAME>"
		def a1 = addressClass.newInstance()
		a1.number = "22"; a1.postCode = "3345243"
		def a2 = addressClass.newInstance()
		a2.number = "454"; a2.postCode = "340854"

		p.homeAddress = a1
		p.workAddress = a2

        p.save()
        session.flush()

        session.clear()

        p = personClass.clazz.get(1)

        assert p
        assert p.homeAddress
        assert p.workAddress

        assertEquals "22", p.homeAddress.number
        assertEquals "3345243", p.homeAddress.postCode
        assertEquals "454", p.workAddress.number
        assertEquals "340854", p.workAddress.postCode

        assertEquals "<NAME>", p.workAddress.person.name


	}

	void onSetUp() {
		this.gcl.parseClass('''
class Person {
	Long id
	Long version
	String name
	Address homeAddress
	Address workAddress

	static embedded = ['homeAddress', 'workAddress']
}
class Address {
	Long id
	Long version
	Person person
	String number
	String postCode
}
'''
		)<commit_msg>test for GRAILS-1637<commit_after>package org.codehaus.groovy.grails.orm.hibernate;

import org.codehaus.groovy.grails.commons.*
import org.codehaus.groovy.grails.commons.test.*

class ComponentMappingTests extends AbstractGrailsHibernateTests {

	void testComponentMapping() {
		def personClass = ga.getDomainClass("Person")
		def addressClass = ga.getDomainClass("Address")

		def p = personClass.newInstance()

		p.name = "<NAME>"
		def a1 = addressClass.newInstance()
		a1.number = "22"; a1.postCode = "3345243"
		def a2 = addressClass.newInstance()
		a2.number = "454"; a2.postCode = "340854"

		p.homeAddress = a1
		p.workAddress = a2

        p.save()
        session.flush()

        session.clear()

        p = personClass.clazz.get(1)

        assert p
        assert p.homeAddress
        assert p.workAddress

        assertEquals "22", p.homeAddress.number
        assertEquals "3345243", p.homeAddress.postCode
        assertEquals "454", p.workAddress.number
        assertEquals "340854", p.workAddress.postCode

        assertEquals "<NAME>", p.workAddress.person.name


	}

	void onSetUp() {
		this.gcl.parseClass('''
class Person {
	Long id
	Long version
	String name
	Address homeAddress
	Address workAddress

	static embedded = ['homeAddress', 'workAddress']
}
class Address {
	Long id
	Long version
	Person person
	String number
	String postCode
}
class StoreItem {
	Long id
	Long version

    String name
    String description
    Price price
    static embedded = ['price']
}

class Price {
	Long id
	Long version
 
    BigDecimal amount
    Integer quantity
}
'''
		)
{'fraction_non_alphanumeric': 0.10320404721753794, 'fraction_numerical': 0.03170320404721754, 'mean_word_length': 3.2130681818181817, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5015669', 'n_tokens_mistral': 1027, 'n_tokens_neox': 910, 'n_words': 223}