Overview of Java Backend Frameworks: Reflection, Annotations, ORM, Hibernate, MyBatis, Struts2, and Spring
This article introduces core Java backend concepts such as reflection and annotations, explains ORM principles, and provides concise overviews of major frameworks—including Hibernate, MyBatis, Struts2, Spring, and Spring MVC—along with related tools like JUnit, SVN, and Maven.
Reflection in Java provides dynamic capabilities, allowing programs to inspect and manipulate classes, methods, and fields at runtime, which is essential for many frameworks.
Annotations simplify code by adding metadata, reducing boilerplate; Java supports both JDK and third‑party annotations.
Object‑Relational Mapping (ORM) abstracts database interactions, letting developers work with objects instead of raw SQL; it solves portability and maintenance issues.
Hibernate is a lightweight open‑source ORM that wraps JDBC, sits between the database and business layers, and offers HQL for queries. Common properties include cascade and inverse. Example mapping:
<hibernate-mapping>
<class name="" table="">
<id name="id" type="java.lang.Long">
<column name="ID" />
<generator class="increment" />
</id>
<many-to-one name="" class="">
<column name="" />
</many-to-one>
...
<set name="" inverse="true" cascade="all" lazy="false">
<key>
<column name="" />
</key>
<one-to-many class="" />
</set>
</class>
</hibernate-mapping>Struts2 is an MVC web framework. It supports dynamic method invocation via the method attribute, an exclamation‑mark syntax, or wildcard patterns. Example configurations:
<action name="" method="" class="">
<result>/index.jsp</result>
</action> <action name="" method="" class="">
<result>/index.jsp</result>
<constant name="struts.enable.DynamicMethodInvocation" value="true" />
</action> <action name="_*" method="{1}" class="">
<result>/index.jsp</result>
<result>/{1}.jsp</result>
</action>Spring is a lightweight IoC container with AOP support. It promotes loose coupling, declarative transaction management, and modular configuration. Core concepts include IoC, AOP, and transaction interfaces such as TransactionDefinition.
Spring MVC implements a front controller (DispatcherServlet) that routes requests to controllers, builds a ModelAndView, and resolves views. Interceptors can pre‑ and post‑process requests, forming a clear request‑processing pipeline.
MyBatis is another ORM framework that separates SQL from Java code, offering manual control over queries. It contrasts with Hibernate’s fully automated mapping and SQL generation.
Additional development tools covered: JUnit for unit testing, SVN for version control, and Maven for project build, dependency management, and artifact publishing.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Java Captain
Focused on Java technologies: SSM, the Spring ecosystem, microservices, MySQL, MyCat, clustering, distributed systems, middleware, Linux, networking, multithreading; occasionally covers DevOps tools like Jenkins, Nexus, Docker, ELK; shares practical tech insights and is dedicated to full‑stack Java development.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
