Skip to content

Instantly share code, notes, and snippets.

@MarkMenard
Created March 22, 2010 21:04
Show Gist options
  • Save MarkMenard/340525 to your computer and use it in GitHub Desktop.
Save MarkMenard/340525 to your computer and use it in GitHub Desktop.
Example Ruby/Java JPA
require 'java'
java_require 'agreement_jpa_impl'
java_package 'models'
java_import 'javax.persistence.*'
java_annotation '@Entity (name="Agreement")'
java_annotation '@Table (name="agreement")'
java_annotation '@EntityListeners ({ QIdSetter.class })'
java_implements 'Agreement'
class AgreementJpaImpl < BaseEntity
java_annotation '@ManyToOne (targetEntity=PartyJpaImpl.class) '
java_attr_accessor :Party, :party
java_annotation '@OneToMany (targetEntity=AgreementLineItemJpaImpl.class, mappedBy="agreement")'
java_attr_accessor 'Set<AgreementLineItem>', :agreementLineItems
java_signature "AgreementJpaImpl ()"
def initialize
super
end
end
class BaseEntity
java_annotation '@Id'
java_attr_accessor :String, :id
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment