Posts

Showing posts from March, 2023

security session tags

Anonymous person <div sec:authorize="isAnonymous()">  </div> Authenticated person <div sec:authorize="isAuthenticated()"> </div> showing Authenticated person name : <span sec:authentication="name">username</span>

convert HTML to thymeleaf Tags Add

 <!DOCTYPE html>         to <html lang="en" xmlns:th="http://www.thymeleaf.org"> -------------------------------------------------------------------------------------------- BASE.HTML <html lang="en" xmlns:th="http://www.thymeleaf.org" th:fragment="layout(content)"  xmlns:sec="https://www.thymeleaf.org/thymeleaf-extras-springsecurity5"> <div th:replace="${content}" class="main">   example.html <html lang="en" xmlns:th="http://www.thymeleaf.org" th:replace="(~{base::layout(~{::section})})"  xmlns:sec="https://www.thymeleaf.org/thymeleaf-extras-springsecurity5"  > <section> ................................................................ </section> -----------------------------------------------------------------------------------------------

javaScript Regex Expression

 javaScript Regex Expression  A regular expression is a  pattern  of characters. The pattern is used to do pattern-matching  "search-and-replace"  functions on text. Syntax / pattern / modifier(s) ; Modifiers Modifiers are used to perform case-insensitive and global searches: Modifier Description g Perform a global match (find all matches rather than stopping after the first match) i Perform case-insensitive matching m Perform multiline matching      <p id="demo"></p> <script> let text = "Visit W3Schools"; let pattern = /w3schools/i; let result = text.match(pattern); document.getElementById("demo").innerHTML = result; </script> o/p :-  W3Schools Brackets Brackets are used to find a range of characters: Expression Description [abc] Find any character between the brackets [^abc] Find any character NOT between the brackets [0-9] Find any character between the brackets (any digit) [^0-9] Find any character NOT between...

Circel Rounding Animation

 Circel Rounding Animation <div class="main">   <div class="circle"></div> </div> -------------------------------------------- body{   background:black; } .main{   width:330px;   height:330px;   border:1px solid #CCC;   position:absolute;   top:0; bottom:0; left:0;right:0;   margin:auto;   border-radius:50%;    border:10px solid white; } .circle{   width:10px;   height:10px;   background:cyan;   border-radius:50%;   position:absolute;   top:0; bottom:0; left:0;right:0;   overflow:hidden;   margin:auto;   animation: circle 2s linear infinite; } @keyframes circle{   0%{     transform:rotate(0deg)               translate(-165px)               rotate(0deg);      }   100%{     transform:rotate(360deg)               tr...

allowing input only for float number & Number

allowing input only for float number & Number  $( 'input.float' ). on ( 'input' , function ( ) { this . value = this . value . replace ( /[^0-9.]/g , '' ). replace ( /(\..*?)\..*/g , '$1' ); }); < script src = "https://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js" > </ script > < input type = "text" class = "float" /> Another, < script src = "https://ajax.googleapis.com/ajax/libs/jquery/1.4.3/jquery.min.js" > </ script > < script src = "https://cdnjs.cloudflare.com/ajax/libs/caret/1.0.0/jquery.caret.min.js" > </ script > < input type = "text" class = "filterme" > $( '.filterme' ). keypress ( function ( eve ) { if ((eve. which != 46 || $( this ). val (). indexOf ( '.' ) != - 1 ) && (eve. which < 48 || eve. which > 57 ) || (eve. which == 46 && $( this ). caret ()....

One To One Query in JPA springboot

 One To One Query in JPA springboot In JPA and Spring Boot, you can perform a one-to-one query using JPQL (Java Persistence Query Language) or by using Spring Data JPA's query methods. Assuming you have two entities, let's call them EntityA and EntityB, with a one-to-one relationship between them, you can write a JPQL query to retrieve EntityA and its associated EntityB as follows: @Entity public class EntityA { @Id private Long id; @OneToOne(mappedBy = "entityA") private EntityB entityB; // ... } @Entity public class EntityB { @Id private Long id; @OneToOne @JoinColumn(name = "entity_a_id") private EntityA entityA; // ... } ------------------------------------------------------------------------------ TypedQuery<EntityA> query = entityManager.createQuery(     "SELECT a FROM EntityA a JOIN FETCH a.entityB b WHERE a.id = :id", EntityA.class); query.setParameter("id", entityId); EntityA e...

Many To Many Query in JPA springboot

  Many To Many Query in JPA springboot To perform a many-to-many query using JPA in Spring Boot, you will typically need to use the @ManyToMany annotation to map the relationship between the entities. Here are the steps you can follow: Define the entities: Let's say you have two entities, Student and Course , with a many-to-many relationship between them. In the Student entity, you can define the relationship as follows: @Entity public class Student {     @Id     private Long id;     private String name;     @ManyToMany     @JoinTable(             name = "student_course",             joinColumns = @JoinColumn(name = "student_id"),             inverseJoinColumns = @JoinColumn(name = "course_id"))     private Set<Course> courses = new HashSet<>(); } Similarly, in the Course entity, you can define the relationship as foll...

One To Many Query in JPA springboot

One To Many Query in JPA springboot In JPA with Spring Boot, you can perform a one-to-many query using the JOIN FETCH clause in a JPQL (Java Persistence Query Language) query. This will allow you to retrieve a single entity and all of its associated child entities in a single database query. Assuming you have an entity named Parent with a one-to-many relationship to Child , where Parent has a Set<Child> property, you can write a JPQL query like this: SELECT p FROM Parent p JOIN FETCH p.children WHERE p.id = :parentId This query will fetch a single Parent entity by its id and eagerly fetch all of its associated Child entities. You can then execute this query using a Spring Data JPA repository interface: public interface ParentRepository extends JpaRepository<Parent, Long> { @Query("SELECT p FROM Parent p JOIN FETCH p.children WHERE p.id = :parentId") Parent findByIdWithChildren(@Param("parentId") Long parentId); } You can then use t...