mybatis / scala Goto Github PK
View Code? Open in Web Editor NEWThe Scala version of MyBatis SQL Mapper
Home Page: http://mybatis.github.io/scala/
License: Apache License 2.0
The Scala version of MyBatis SQL Mapper
Home Page: http://mybatis.github.io/scala/
License: Apache License 2.0
The links to both core and sample documentation are broken (404) at http://mybatis.github.io/scala/ . There are many google-able links that lead there (including at the main mybatis site) - you have to really work to find a link to the docs at
http://mybatis.github.io/scala/mybatis-scala-core_2.10/index.html
http://mybatis.github.io/scala/mybatis-scala-samples_2.10/index.html
which I'm guessing are current.
Also, all the links on http://mybatis.github.io/scala/mybatis-scala-samples_2.10/index.html are broken.
will have fix later for this, marking it so we know why...
Need to ensure we can build for jdk 11 as with all other mybatis projects. This one is still not yet compliant and likely due to scala itself at the revision used. Review the results on travis ci as to failure condition.
When including a conditional expression to create dynamic SQL using "choose" and enclosed "when" and "otherwise" tags, a Scala MatchError is thrown if there is any whitespace between the tags.
E.g. this works ok:
<choose><when test="sometest">xx</when><otherwise>yy</otherwise></choose>
but this doesn't and throws a MatchError in line 74 of DynamicSQLBuilder.scala:
<choose> <when test="sometest">xx</when> <otherwise>yy</otherwise> </choose>
Original issue at http://code.google.com/p/mybatis/issues/detail?id=768
We need to ensure that we generate both a scala 2.9 and 2.10 version of mybatis-scala
I have been wrestling with the most basic join possible--between Person and Address--for hours today, and I would simply like to know if this is possible with immutable case classes. Or do I have to make my fields mutable as in the sample? I would rather I just ask before I go through the extensive effort to make them mutable only to find my code ripped off from the samples still doesn't work.
Thanks.
It looks like the cache in DefaultObjectFactory isn't thread safe. If you have a Configuration that is shared across threads (which I think is legal?), getConstructor can be called concurrently. That might get touched enough that it's not worth making that a SynchronizedMap and maybe should just jump straight to a ConcurrentHashMap. Interestingly the Java implementation of DefaultObjectFactory doesn't cache at all. Is that just a Scala tax?
I currently have a Person to Address mapping in a 1:M relationship. When I insert a Person bean that has a populated mutable.Seq[Address] in it, I find no exceptions, but the Person instance is inserted while the Address instances are not. I have this in my Person ResultMapping:
collection[Address](
property = "addresses", //as the bean has person.addresses
resultMap = Address.addressResultMap,
column = "p_id",
notNullColumn = "p_id"
)
The result is the same whether those last two values are there or not--or one at a time.
Is there something I need to add to Address to tell MyBatis (Scala) where Person's foreign key in Address is? Or what else should I look at to insert the children in this 1:M relationship?
Thanks.
In my project I usually define case classes for mapping, like this:
case class SomeEntity(key: String, values: Seq[String]) {
def this() = this(null, Seq.empty)
}
Today I tried to do the following thing:
val select = new SelectListBy[Int, SomeEntity] {
resultMap = new ResultMap[SomeEntity] {
result(column = "key", property = "key")
collection[String](property = "values", resultMap = new ResultMap[String] {
})
}
def xsql = <xsql>SELECT key, some_column_name FROM ... WHERE xyz={"id"?}
</xsql>
}
And now:
class SomeEntity {
var key: String = _
var values: Seq[String] = _
}
Expected results:
in java version i do like this
DataSource dataSource = BlogDataSourceFactory.getBlogDataSource();
TransactionFactory transactionFactory =
new JdbcTransactionFactory();
Environment environment =
new Environment("development", transactionFactory, dataSource);
Configuration configuration = new Configuration(environment);
configuration.addMapper(BlogMapper.class);
SqlSessionFactory sqlSessionFactory =
new SqlSessionFactoryBuilder().build(configuration);
org.apache.ibatis.reflection.Reflector always returns null for _1 and _2 properites of Tuple2 type. The code below always puts null in _1 and _2 placeholders:
val insert = new Insert[Tuple2[Int, Int]] {
def xsql = <xsql>INSERT INTO some_table(col1, col2) VALUES ({ "_1"? } ,{ "_2"? }) </xsql>
}
Interrestingly, it works for Tuple3 :) Tested against mybatis scala 1.0.1
how can I get the generated key of an insert with scala bind?
In Scala, the use of 'properties' (e.g. methods without parens) should be reserved to things that are property-like.
So, for instance, if you have a class Person, it's perfectly reasonable to have a method declared:
def name
But as far as I know it's not considered idiomatic to have a method such as:
def saveToDatabase
But rather you'd define it:
def saveToDatabase()
I noticed that in the session class you have a lot of paren-less methods that seem to be, well, methods, and I think violate the above rule.
Fortunately, you can fix this if you choose (by adding empty parens to all relevant methods) without breaking backward compatibility.
This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.
This repository currently has no open or pending branches.
.github/workflows/ci.yaml
actions/checkout v4
actions/setup-java v4
.github/workflows/codeql.yml
actions/checkout v4
actions/setup-java v4
github/codeql-action v3
github/codeql-action v3
github/codeql-action v3
.github/workflows/coveralls.yaml
actions/checkout v4
actions/setup-java v4
.github/workflows/site.yaml
actions/checkout v4
actions/setup-java v4
JamesIves/github-pages-deploy-action v4
.github/workflows/sonar.yaml
actions/checkout v4
actions/setup-java v4
.github/workflows/sonatype.yaml
actions/checkout v4
actions/setup-java v4
mybatis-scala-core/pom.xml
org.mybatis.scala:mybatis-scala-parent_2.13 1.3.2-SNAPSHOT
org.mybatis:mybatis 3.5.16
org.scalatest:scalatest_2.13 3.2.19
org.hsqldb:hsqldb 2.7.3
org.scalatest:scalatest-maven-plugin 2.2.0
net.alchim31.maven:scala-maven-plugin 4.9.2
mybatis-scala-samples/pom.xml
org.mybatis.scala:mybatis-scala-parent_2.13 1.3.2-SNAPSHOT
org.hsqldb:hsqldb 2.7.3
pom.xml
org.mybatis:mybatis-parent 45
org.scala-lang:scala-library 2.13.14
org.scala-lang.modules:scala-xml_2.13 2.3.0
net.alchim31.maven:scala-maven-plugin 4.9.2
.mvn/wrapper/maven-wrapper.properties
maven 3.9.9
maven-wrapper 3.3.2
Cause: java.lang.IllegalArgumentException: Mapped Statements collection does not contain value for _DEFAULT_.com-xx-xx-xx-xx-xx-UserDAO$$anon$1-1
Since maven-site-plugin 3.3 has not been supported the <reportPlugins>
element on <configuration>
.
Invalid configuration:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<configuration>
<reportPlugins> <!-- ### Invalid definition ### -->
<plugin>
<groupId>org.scala-tools</groupId>
<artifactId>maven-scala-plugin</artifactId>
<version>2.15.2</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-changes-plugin</artifactId>
<version>2.12.1</version>
<reportSets>
<reportSet>
<reports>
<report>changes-report</report>
</reports>
</reportSet>
</reportSets>
</plugin>
</reportPlugins>
</configuration>
</plugin>
For details see https://maven.apache.org/plugins/maven-site-plugin/maven-3.html#Configuration_formats.
Any example code for it?
i found mybatis-3-config.dtd :
<!ELEMENT environments (environment+)>
<!ATTLIST environments
default CDATA #REQUIRED
>
but how to change the datasource in the code?
[info] Compiling 15 Scala sources to /Users/hary/workspace/scala/mybatis-scala-samples/target/scala-2.11/classes...
[info] 'compiler-interface' not yet compiled for Scala 2.11.6. Compiling...
[info] Compilation completed in 7.338 s
[error] /Users/hary/workspace/scala/mybatis-scala-samples/src/main/scala/org/mybatis/scala/samples/performance/ProfileTest.scala:97: method handle: (callback: org.mybatis.scala.session.ResultContext => Unit)(implicit s: org.mybatis.scala.session.Session)Unit does not take type parameters.
[error] select.handle[TestBean] { context =>
[error] ^
[error] one error found
[error] (compile:compileIncremental) Compilation failed
[error] Total time: 9 s, completed 2017-6-19 20:33:49
hi guys,
I'm getting this compilation error on a fresh git clone of master:
D:\dev\mybatis\mybatis-scala\mybatis-scala-core\src\main\scala\org\mybatis\scala\config\ConfigurationSpace.scala
Error:(79, 33) not enough arguments for method useNewCache: (x$1: Class[_ <: org.apache.ibatis.cache.Cache], x$2: Class[_ <: org.apache.ibatis.cache.Cache], x$3: Long, x$4: Integer, x$5: Boolean, x$6: Boolean, x$7: java.util.Properties)org.apache.ibatis.cache.Cache.
Unspecified value parameter x$7
builderAssistant.useNewCache(
^
this seems to be related to a new parameter required by the useNewCache method, 'boolean blocking'.
does anyone know when did this start failing? it seems to be that the mybatis dependency was upgraded to v3.3.0 on July, is it possible that this broke the build?
if so, how comes travis CI didn't catch this?
a more concrete question, how should this be fixed? it's quite easy to add this parameter throughout the call chain, but at the end there's supposed to be a reasonable default to, anyone knows what this default is?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.