<commit_before>package org.squeryl.test.schooldb2

import org.squeryl.PrimitiveTypeMode._
import org.squeryl._
import dsl.ast._
import dsl.{OneToMany, CompositeKey2}
import java.sql.{Savepoint}

import org.squeryl.framework._

trait SchoolDb2Object extends KeyedEntity[Long] {
  val id: Long = 0
}

object SchoolDb2 extends SchoolDb2

class Professor(val lastName: String, var bossId: Option[Long]=None) extends SchoolDb2Object {

  lazy val courses = SchoolDb2.courseAssignments.left(this)
}

class Course(val subjectId: Long) extends SchoolDb2Object {

  def this() = this(0)

  // Lets support the case where a course can have more than one professor
  lazy val professors = SchoolDb2.courseAssignments.right(this)

  lazy val students = SchoolDb2.courseSubscriptions.left(this)

  lazy val subject = SchoolDb2.subjectToCourses.right(this)
}

class Student(val firstName: String, val lastName: String) extends SchoolDb2Object {  
  
  lazy val courses = SchoolDb2.courseSubscriptions.right(this)

  def fullName = compositeKey(firstName, lastName)
}

class Subject(val name: String, val parentSubjectId: Option[Long]) extends SchoolDb2Object {
  
  lazy val courses = SchoolDb2.subjectToCourses.left(this)
  
  lazy val childSubjects = SchoolDb2.subjectToParentSubject.left(this)
  
  lazy val parentSubject = SchoolDb2.subjectToParentSubject.right(this)
}

class CourseSubscription(val courseId: Long, val studentId: Long, var grade: Float) extends KeyedEntity[CompositeKey2[Long,Long]] {

  def id = compositeKey(courseId, studentId)
}

class CourseAssignment(val courseId: Long, val professorId: Long) extends KeyedEntity[CompositeKey2[Long,Long]] {

  def id = compositeKey(courseId, professorId)
}

case class Entry(text: String) extends KeyedEntity[Int] {
 val id:Int = 0
 // entryToComments is a one-to-many relation:
 lazy val comments: OneToMany[Comment] = SchoolDb2.entryToComments.left(this)
}

case class Comment(text: String, entryId: Int = 0, userId: Int = 0)
   extends KeyedEntity[Int] {
 val id:Int = 0
}



class ASTConstructionInterferenceA extends KeyedEntity[Long] {
  val id: Long = 0

  lazy val bs = SchoolDb2.aToB.left(this)
}

class ASTConstructionInterferenceB(val aId: Long) extends KeyedEntity[Long] {
  val id: Long = 0

  val field1 = "abc"
  val field2 = field1
}



class SchoolDb2 extends Schema {

  val entries = table[Entry]
  val comments = table[Comment]("commentz")<commit_msg>test case for KeyedEntityDef with relations<commit_after>package org.squeryl.test.schooldb2

import org.squeryl.PrimitiveTypeMode._
import org.squeryl._
import dsl.ast._
import dsl.{OneToMany, CompositeKey2}
import java.sql.{Savepoint}

import org.squeryl.framework._

trait SchoolDb2Object {
  val id: Long = 0
}

object SchoolDb2 extends SchoolDb2

class Professor(val lastName: String, var bossId: Option[Long]=None) extends SchoolDb2Object {

  lazy val courses = SchoolDb2.courseAssignments.left(this)
}

class Course(val subjectId: Long) extends SchoolDb2Object {

  def this() = this(0)

  // Lets support the case where a course can have more than one professor
  lazy val professors = SchoolDb2.courseAssignments.right(this)

  lazy val students = SchoolDb2.courseSubscriptions.left(this)

  lazy val subject = SchoolDb2.subjectToCourses.right(this)
}

class Student(val firstName: String, val lastName: String) extends SchoolDb2Object {  
  
  lazy val courses = SchoolDb2.courseSubscriptions.right(this)

  def fullName = compositeKey(firstName, lastName)
}

class Subject(val name: String, val parentSubjectId: Option[Long]) extends SchoolDb2Object {
  
  lazy val courses = SchoolDb2.subjectToCourses.left(this)
  
  lazy val childSubjects = SchoolDb2.subjectToParentSubject.left(this)
  
  lazy val parentSubject = SchoolDb2.subjectToParentSubject.right(this)
}

class CourseSubscription(val courseId: Long, val studentId: Long, var grade: Float) extends KeyedEntity[CompositeKey2[Long,Long]] {

  def id = compositeKey(courseId, studentId)
}

class CourseAssignment(val courseId: Long, val professorId: Long) extends KeyedEntity[CompositeKey2[Long,Long]] {

  def id = compositeKey(courseId, professorId)
}

case class Entry(text: String) extends KeyedEntity[Int] {
 val id:Int = 0
 // entryToComments is a one-to-many relation:
 lazy val comments: OneToMany[Comment] = SchoolDb2.entryToComments.left(this)
}

case class Comment(text: String, entryId: Int = 0, userId: Int = 0)
   extends KeyedEntity[Int] {
 val id:Int = 0
}



class ASTConstructionInterferenceA extends KeyedEntity[Long] {
  val id: Long = 0

  lazy val bs = SchoolDb2.aToB.left(this)
}

class ASTConstructionInterferenceB(val aId: Long) extends KeyedEntity[Long] {
  val id: Long = 0

  val field1 = "abc"
  val field2 = field1
}



class SchoolDb2 extends Schema {

  implicit object schoolDbObjectKED extends KeyedEntityDef[SchoolDb2Object,Long] {
    def idF = (a:SchoolDb2Object) => a.id
    def isPersisted = (a:SchoolDb2Object) => a.id > 0
    def idPropertyName = "id"
  }
  
  val entries = table[Entry]
  val comments = table[Comment]("commentz")
{'fraction_non_alphanumeric': 0.09031620553359684, 'fraction_numerical': 0.01383399209486166, 'mean_word_length': 4.996445497630332, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, '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': '6958008', 'n_tokens_mistral': 1659, 'n_tokens_neox': 1625, 'n_words': 445}